void NegateMagicSpell::Update() { LaunchAntiMagicField(); if(m_target == EntityHandle_Player) { m_pos = player.basePosition(); } else { Entity * target = entities.get(m_target); if(target) { m_pos = target->pos; } } Vec3f stitepos = m_pos - Vec3f(0.f, 10.f, 0.f); RenderMaterial mat; mat.setLayer(RenderMaterial::Decal); mat.setDepthTest(true); mat.setTexture(tex_sol); mat.setBlendType(RenderMaterial::Additive); for(int i = 0; i < 360; i++) { float t = Random::getf(); if(t < 0.04f) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = stitepos + arx::randomOffsetXZ(150.f); pd->move = Vec3f(0.f, Random::getf(-3.f, 0.f), 0.f); pd->siz = 0.3f; pd->tolive = Random::getu(2000, 4000); pd->tc = tex_p2; pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING | SUBSTRACT; pd->m_rotation = 0.0000001f; } } float rot = timeWaveSaw(g_gameTime.now(), GameDurationMs(18000)) * 360.f; Anglef stiteangle(0.f, -rot, 0.f); float scalediff = timeWaveSin(g_gameTime.now(), GameDurationMsf(1570.79632f)); { Color3f stitecolor = Color3f::gray(.4f); Vec3f stitescale = Vec3f(3.f + 0.5f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); } { Color3f stitecolor = Color3f(.5f, 0.f, .5f); Vec3f stitescale = Vec3f(3.1f + 0.2f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); } }
void NegateMagicSpell::Update() { LaunchAntiMagicField(); if(m_target == PlayerEntityHandle) { m_pos = player.basePosition(); } else { m_pos = entities[m_target]->pos; } Vec3f stitepos = m_pos - Vec3f(0.f, 10.f, 0.f); RenderMaterial mat; mat.setLayer(RenderMaterial::Decal); mat.setDepthTest(true); mat.setTexture(tex_sol); mat.setBlendType(RenderMaterial::Additive); for(int i = 0; i < 360; i++) { float t = Random::getf(); if(t < 0.04f) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = stitepos + Vec3f(Random::getf(-150.f, 150.f), 0.f, Random::getf(-150.f, 150.f)); pd->move = Vec3f(0.f, Random::getf(-3.f, 0.f), 0.f); pd->siz = 0.3f; pd->tolive = Random::getu(2000, 4000); pd->tc = tex_p2; pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT; pd->fparam = 0.0000001f; } } float now = arxtime.now_f(); Anglef stiteangle(0.f, -now * 0.02f, 0.f); float scalediff = std::sin(now * 0.004f); { Color3f stitecolor = Color3f::gray(.4f); Vec3f stitescale = Vec3f(3.f + 0.5f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); } { Color3f stitecolor = Color3f(.5f, 0.f, .5f); Vec3f stitescale = Vec3f(3.1f + 0.2f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); } }
void CRuneOfGuarding::Render() { Vec3f pos = eSrc + Vec3f(0.f, -20.f, 0.f); RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef stiteangle; Color3f stitecolor; float stiteangleb = float(ulCurrentTime) * 0.01f; stiteangle.setYaw(0); stiteangle.setRoll(0); stiteangle.setPitch(stiteangleb * 0.1f); stitecolor = Color3f(0.4f, 0.4f, 0.6f); float scale = std::sin(ulCurrentTime * 0.015f); Vec3f stitescale = Vec3f(1.f, -0.1f, 1.f); Draw3DObject(slight, stiteangle, pos, stitescale, stitecolor, mat); stiteangle.setPitch(stiteangleb); stitecolor = Color3f(0.6f, 0.f, 0.f); stitescale = Vec3f(2.f) * (1.f + 0.01f * scale); Draw3DObject(ssol, stiteangle, pos, stitescale, stitecolor, mat); stitecolor = Color3f(0.6f, 0.3f, 0.45f); stitescale = Vec3f(1.8f) * (1.f + 0.02f * scale); Draw3DObject(srune, stiteangle, pos, stitescale, stitecolor, mat); for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = pos + (Vec3f(40.f, 0.f, 40.f) * Vec3f(frand2(), 0.f, frand2())); pd->move = Vec3f(0.8f, -4.f, 0.8f) * Vec3f(frand2(), rnd(), frand2()); pd->scale = Vec3f(-0.1f); pd->tolive = Random::get(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } }
void CCurse::Render() { RenderMaterial mat; mat.setCulling(Renderer::CullCW); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Opaque); Anglef stiteangle = Anglef(0, fRot, 0); Vec3f stitepos = eTarget; Vec3f stitescale = Vec3f_ONE; Color3f stitecolor = Color3f::white; Draw3DObject(svoodoo, stiteangle, stitepos, stitescale, stitecolor, mat); for(int i = 0; i < 4; i++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = eTarget; pd->move = Vec3f(2.f * frand2(), rnd() * -10.f - 10.f, 2.f * frand2()); pd->siz = 0.015f; pd->tolive = Random::get(1000, 1600); pd->tc = tex_p1; pd->special = ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT | GRAVITY; pd->fparam = 0.0000001f; } }
void ARXDRAW_DrawEyeBall() { if(eyeball.exist == 0 || !eyeballobj) return; float d; if(eyeball.exist < 0) { d = (float)(-eyeball.exist)*( 1.0f / 100 ); eyeball.exist++; } else if(eyeball.exist > 2) { d = (float)(eyeball.exist)*( 1.0f / 100 ); } else return; Anglef angle = eyeball.angle; angle.setPitch(MAKEANGLE(180.f - angle.getPitch())); Vec3f pos = eyeball.pos; pos.y += eyeball.floating; Vec3f scale = Vec3f(d); Color3f rgb = Color3f::gray(d); RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Draw3DObject(eyeballobj, angle, pos, scale, rgb, mat); }
void CNegateMagic::Render() { int i = 0; Vec3f stitepos = eSrc - Vec3f(0.f, 10.f, 0.f); if(ulCurrentTime >= ulDuration) return; RenderMaterial mat; mat.setLayer(RenderMaterial::Decal); mat.setDepthTest(true); mat.setTexture(tex_sol); mat.setBlendType(RenderMaterial::Additive); for(i = 0; i < 360; i++) { float t = rnd(); if(t < 0.04f) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = stitepos + Vec3f(frand2() * 150.f, 0.f, frand2() * 150.f); pd->move = Vec3f(0.f, -3.0f * rnd(), 0.f); pd->siz = 0.3f; pd->tolive = Random::get(2000, 4000); pd->tc = tex_p2; pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT; pd->fparam = 0.0000001f; } } Anglef stiteangle(0.f, -(float) ulCurrentTime * 0.02f, 0.f); Color3f stitecolor = Color3f::gray(.4f); float scalediff = std::sin(ulCurrentTime * 0.004f); Vec3f stitescale = Vec3f(3.f + 0.5f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); stitecolor = Color3f(.5f, 0.f, .5f); stitescale = Vec3f(3.1f + 0.2f * scalediff); Draw3DObject(ssol, stiteangle, stitepos, stitescale, stitecolor, mat); }
void CRepelUndead::Render() { if(ulCurrentTime >= ulDuration) return; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef eObjAngle; eObjAngle.setPitch(m_yaw); eObjAngle.setYaw(0); eObjAngle.setRoll(0); float vv = 1.f + (std::sin(arxtime.get_updated() * ( 1.0f / 1000 ))); vv *= ( 1.0f / 2 ); vv += 1.1f; Draw3DObject(ssol, eObjAngle, eSrc + Vec3f(0.f, -5.f, 0.f), Vec3f(vv), Color3f(0.6f, 0.6f, 0.8f), mat); vv *= 100.f; for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } float dx = -std::sin(frand2() * 360.f) * vv; float dz = std::cos(frand2() * 360.f) * vv; pd->ov = eSrc + Vec3f(dx, 0.f, dz); pd->move = Vec3f(0.8f * frand2(), -4.f * rnd(), 0.8f * frand2()); pd->scale = Vec3f(-0.1f); pd->tolive = Random::get(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } if(!lightHandleIsValid(lLightId)) { lLightId = GetFreeDynLight(); } if(lightHandleIsValid(lLightId)) { EERIE_LIGHT * light = lightHandleGet(lLightId); light->intensity = 2.3f; light->fallend = 350.f; light->fallstart = 150.f; light->rgb = Color3f(0.8f, 0.8f, 1.f); light->pos = eSrc + Vec3f(0.f, -50.f, 0.f); light->duration = 200; light->time_creation = (unsigned long)(arxtime); } }
void CLevitate::DrawStone() { RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Screen); int nb = 256; while(nb--) { T_STONE & s = tstone[nb]; if(s.actif) { float a = (float)s.currtime / (float)s.time; if(a > 1.f) { a = 1.f; s.actif = 0; } Color4f col = Color4f(Color3f::white, 1.f - a); EERIE_3DOBJ * obj = (s.numstone == 0) ? stone0 : stone1; Draw3DObject(obj, s.ang, s.pos, s.scale, Color4f(col), mat); PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = s.pos; pd->move = Vec3f(0.f, 3.f * rnd(), 0.f); pd->siz = 3.f + 3.f * rnd(); pd->tolive = 1000; pd->timcreation = -(long(arxtime) + 1000l); // TODO WTF? pd->special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->fparam = 0.0000001f; } //update mvt if(!arxtime.is_paused()) { a = (((float)this->currframetime) * 100.f) / (float)s.time; s.pos.y += s.yvel * a; s.ang += s.angvel * a; s.yvel *= 1.f - (1.f / 100.f); s.currtime += this->currframetime; } } } }
void CRiseDead::DrawStone() { int nb = 256; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Screen); while(nb--) { if(this->tstone[nb].actif) { float a = (float)this->tstone[nb].currtime / (float)this->tstone[nb].time; if(a > 1.f) { a = 1.f; this->tstone[nb].actif = 0; } Color4f col = Color4f(Color3f::white, 1.f - a); Draw3DObject(stone[tstone[nb].numstone], tstone[nb].ang, tstone[nb].pos, tstone[nb].scale, col, mat); PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = tstone[nb].pos; pd->move = Vec3f(0.f, 3.f * rnd(), 0.f); pd->siz = 3.f + 3.f * rnd(); pd->tolive = 1000; pd->timcreation = -(long(arxtime) + 1000l); // TODO WTF pd->special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->fparam = 0.0000001f; } //update mvt if(!arxtime.is_paused()) { a = (((float)this->currframetime) * 100.f) / (float)this->tstone[nb].time; tstone[nb].pos.y += tstone[nb].yvel * a; tstone[nb].ang += tstone[nb].angvel * a; this->tstone[nb].yvel *= 1.f - (1.f / 100.f); this->tstone[nb].currtime += this->currframetime; } } } }
void CurseSpell::Update() { fRot += g_gameTime.lastFrameDuration() / GameDurationMs(4); Vec3f target = Vec3f_ZERO; Entity * targetIo = entities.get(m_target); if(targetIo) { target = targetIo->pos; if(m_target == EntityHandle_Player) target.y -= 200.f; else target.y += targetIo->physics.cyl.height - 30.f; } m_pos = target; RenderMaterial mat; mat.setCulling(CullCW); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Opaque); Draw3DObject(svoodoo, Anglef(0, fRot, 0), m_pos, Vec3f_ONE, Color3f::white, mat); for(int i = 0; i < 4; i++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = m_pos; pd->move = arx::linearRand(Vec3f(-2.f, -20.f, -2.f), Vec3f(2.f, -10.f, 2.f)); pd->siz = 0.015f; pd->tolive = Random::getu(1000, 1600); pd->tc = tex_p1; pd->m_flags = ROTATING | DISSIPATING | SUBSTRACT | GRAVITY; pd->m_rotation = 0.0000001f; } }
static void drawDebugFogs() { RenderMaterial mat; mat.setBlendType(RenderMaterial::Opaque); mat.setDepthTest(true); for(size_t i = 0; i < MAX_FOG; i++) { const FOG_DEF & fog = fogs[i]; if(!fog.exist) { continue; } Draw3DObject(g_fogObject, Anglef(0.f, 0.f, 0.f), fog.pos, Vec3f(1.f), Color3f::white, mat); if(fog.special & FOG_DIRECTIONAL) { drawLine(fog.pos, fog.pos + fog.move * 50.f, Color::white); } drawLineSphere(Sphere(fog.pos, fog.size), Color(Color3<u8>::blue, 200)); } }
void CurseSpell::Update(float timeDelta) { fRot += timeDelta * 0.25f; Vec3f target = Vec3f_ZERO; if(ValidIONum(m_target)) { target = entities[m_target]->pos; if(m_target == PlayerEntityHandle) target.y -= 200.f; else target.y += entities[m_target]->physics.cyl.height - 30.f; } m_pos = target; RenderMaterial mat; mat.setCulling(Renderer::CullCW); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Opaque); Draw3DObject(svoodoo, Anglef(0, fRot, 0), m_pos, Vec3f_ONE, Color3f::white, mat); for(int i = 0; i < 4; i++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = m_pos; pd->move = Vec3f(2.f * frand2(), rnd() * -10.f - 10.f, 2.f * frand2()); pd->siz = 0.015f; pd->tolive = Random::get(1000, 1600); pd->tc = tex_p1; pd->special = ROTATING | MODULATE_ROTATION | DISSIPATING | SUBSTRACT | GRAVITY; pd->fparam = 0.0000001f; } }
void IceFieldSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); if(!lightHandleIsValid(m_light)) m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * el = lightHandleGet(m_light); el->pos = m_pos + Vec3f(0.f, -120.f, 0.f); el->intensity = 4.6f; el->fallstart = 150.f+rnd()*30.f; el->fallend = 290.f+rnd()*30.f; el->rgb = Color3f(0.76f, 0.76f, 1.0f) + Color3f(0.f, 0.f, -rnd()*(1.0f/10)); el->duration = 600; el->extras=0; } if(!VisibleSphere(Sphere(m_pos - Vec3f(0.f, 120.f, 0.f), 350.f))) return; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); for(int i = 0; i < iMax; i++) { tSize[i] += Vec3f(0.1f); tSize[i] = glm::min(tSize[i], tSizeMax[i]); Anglef stiteangle = Anglef::ZERO; Vec3f stitepos; Vec3f stitescale; Color3f stitecolor; stiteangle.setPitch(glm::cos(glm::radians(tPos[i].x)) * 360); stitepos.x = tPos[i].x; stitepos.y = m_pos.y; stitepos.z = tPos[i].z; stitecolor.r = tSizeMax[i].y * 0.7f; stitecolor.g = tSizeMax[i].y * 0.7f; stitecolor.b = tSizeMax[i].y * 0.9f; if(stitecolor.r > 1) stitecolor.r = 1; if(stitecolor.g > 1) stitecolor.g = 1; if(stitecolor.b > 1) stitecolor.b = 1; stitescale.z = tSize[i].x; stitescale.y = tSize[i].y; stitescale.x = tSize[i].z; EERIE_3DOBJ * obj = (tType[i] == 0) ? smotte : stite; Draw3DObject(obj, stiteangle, stitepos, stitescale, stitecolor, mat); } for(int i = 0; i < iMax * 0.5f; i++) { float t = rnd(); if(t < 0.01f) { PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = tPos[i] + randomVec(-5.f, 5.f); pd->move = randomVec(-2.f, 2.f); pd->siz = 20.f; pd->tolive = Random::get(2000, 6000); pd->tc = tex_p2; pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->fparam = 0.0000001f; pd->rgb = Color3f(0.7f, 0.7f, 1.f); } } else if (t > 0.095f) { PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = tPos[i] + randomVec(-5.f, 5.f) + Vec3f(0.f, 50.f, 0.f); pd->move = Vec3f(0.f, 2.f - 4.f * rnd(), 0.f); pd->siz = 0.5f; pd->tolive = Random::get(2000, 6000); pd->tc = tex_p1; pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->fparam = 0.0000001f; pd->rgb = Color3f(0.7f, 0.7f, 1.f); } } } }
void IceFieldSpell::Update() { EERIE_LIGHT * el = dynLightCreate(m_light); if(el) { el->pos = m_pos + Vec3f(0.f, -120.f, 0.f); el->intensity = 4.6f; el->fallstart = Random::getf(150.f, 180.f); el->fallend = Random::getf(290.f, 320.f); el->rgb = Color3f(0.76f, 0.76f, 1.0f) + Color3f(0.f, 0.f, Random::getf(-0.1f, 0.f)); el->duration = ArxDurationMs(600); el->extras=0; } if(!VisibleSphere(Sphere(m_pos - Vec3f(0.f, 120.f, 0.f), 350.f))) return; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); for(int i = 0; i < iMax; i++) { tSize[i] += Vec3f(0.1f); tSize[i] = glm::min(tSize[i], tSizeMax[i]); Anglef stiteangle = Anglef::ZERO; Vec3f stitepos; Vec3f stitescale; Color3f stitecolor; stiteangle.setYaw(glm::cos(glm::radians(tPos[i].x)) * 360); stitepos.x = tPos[i].x; stitepos.y = m_pos.y; stitepos.z = tPos[i].z; stitecolor.r = tSizeMax[i].y * 0.7f; stitecolor.g = tSizeMax[i].y * 0.7f; stitecolor.b = tSizeMax[i].y * 0.9f; if(stitecolor.r > 1) stitecolor.r = 1; if(stitecolor.g > 1) stitecolor.g = 1; if(stitecolor.b > 1) stitecolor.b = 1; stitescale.z = tSize[i].x; stitescale.y = tSize[i].y; stitescale.x = tSize[i].z; EERIE_3DOBJ * obj = (tType[i] == 0) ? smotte : stite; Draw3DObject(obj, stiteangle, stitepos, stitescale, stitecolor, mat); } for(int i = 0; i < iMax * 0.5f; i++) { float t = Random::getf(); if(t < 0.01f) { PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = tPos[i] + randomVec(-5.f, 5.f); pd->move = randomVec(-2.f, 2.f); pd->siz = 20.f; pd->tolive = Random::getu(2000, 6000); pd->tc = tex_p2; pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING; pd->m_rotation = 0.0000001f; pd->rgb = Color3f(0.7f, 0.7f, 1.f); } } else if (t > 0.095f) { PARTICLE_DEF * pd = createParticle(); if(pd) { pd->ov = tPos[i] + randomVec(-5.f, 5.f) + Vec3f(0.f, 50.f, 0.f); pd->move = Vec3f(0.f, Random::getf(-2.f, 2.f), 0.f); pd->siz = 0.5f; pd->tolive = Random::getu(2000, 6000); pd->tc = tex_p1; pd->m_flags = FADE_IN_AND_OUT | ROTATING | DISSIPATING; pd->m_rotation = 0.0000001f; pd->rgb = Color3f(0.7f, 0.7f, 1.f); } } } }
void CMagicMissile::Render() { Vec3f lastpos, newpos; Vec3f v; if(ulCurrentTime >= ulDuration) return; RenderMaterial mat; mat.setCulling(CullNone); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); if(tex_mm) mat.setTexture(tex_mm); if(bMove) { float fOneOnDuration = 1.f / (float)(ulDuration); fTrail = (ulCurrentTime * fOneOnDuration) * (iBezierPrecision + 2) * 5; } newpos = lastpos = pathways[0]; for(int i = 0; i < 5; i++) { const Vec3f v1 = pathways[std::max(0, i - 1)]; const Vec3f v2 = pathways[i]; const Vec3f v3 = pathways[i + 1]; const Vec3f v4 = pathways[std::min(5, i + 2)]; for(int toto = 1; toto < iBezierPrecision; toto++) { if(fTrail < i * iBezierPrecision + toto) break; float t = toto * (1.0f / iBezierPrecision); v = glm::catmullRom(v1, v2, v3, v4, t); newpos = v; if(!((fTrail - (i * iBezierPrecision + toto)) > iLength)) { float c; if(fTrail < iLength) { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / fTrail); } else { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / (float)iLength); } float fsize = c; float alpha = c - 0.2f; if(alpha < 0.2f) alpha = 0.2f; c += Random::getf(-0.1f, 0.1f); c = glm::clamp(c, 0.f, 1.f); Color color = (m_trailColor * (c * alpha)).to<u8>(); if(fsize < 0.5f) fsize = fsize * 2 * 3; else fsize = (1.0f - fsize + 0.5f) * 2 * (3 * 0.5f); float fs = fsize * 6 + Random::getf(0.f, 0.3f); float fe = fsize * 6 + Random::getf(0.f, 0.3f); Draw3DLineTexNew(mat, lastpos, newpos, color, color, fs, fe); } Vec3f temp_vector = lastpos; lastpos = newpos; newpos = temp_vector; } } Vec3f av = newpos - lastpos; float bubu = getAngle(av.x, av.z, 0, 0); float bubu1 = getAngle(av.x, av.y, 0, 0); eCurPos = lastpos; Anglef stiteangle; stiteangle.setPitch(-glm::degrees(bubu)); stiteangle.setYaw(0); stiteangle.setRoll(-(glm::degrees(bubu1))); if(av.x < 0) stiteangle.setRoll(stiteangle.getRoll() - 90); if(av.x > 0) stiteangle.setRoll(stiteangle.getRoll() + 90); if(stiteangle.getRoll() < 0) stiteangle.setRoll(stiteangle.getRoll() + 360.0f); Draw3DObject(smissile, stiteangle, eCurPos, Vec3f_ONE, m_projectileColor, mat); }
void RuneOfGuardingSpell::Update(float timeDelta) { ulCurrentTime += timeDelta; if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); float fa = 1.0f - rnd() * 0.15f; light->intensity = 0.7f + 2.3f * fa; light->fallend = 350.f; light->fallstart = 150.f; light->rgb = Color3f(1.0f, 0.2f, 0.2f); light->time_creation = (unsigned long)(arxtime); light->duration = 200; } Vec3f pos = m_pos + Vec3f(0.f, -20.f, 0.f); RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef stiteangle; Color3f stitecolor; float stiteangleb = float(ulCurrentTime) * 0.01f; stiteangle.setYaw(0); stiteangle.setRoll(0); stiteangle.setPitch(stiteangleb * 0.1f); stitecolor = Color3f(0.4f, 0.4f, 0.6f); float scale = std::sin(ulCurrentTime * 0.015f); Vec3f stitescale = Vec3f(1.f, -0.1f, 1.f); Draw3DObject(slight, stiteangle, pos, stitescale, stitecolor, mat); stiteangle.setPitch(stiteangleb); stitecolor = Color3f(0.6f, 0.f, 0.f); stitescale = Vec3f(2.f) * (1.f + 0.01f * scale); Draw3DObject(ssol, stiteangle, pos, stitescale, stitecolor, mat); stitecolor = Color3f(0.6f, 0.3f, 0.45f); stitescale = Vec3f(1.8f) * (1.f + 0.02f * scale); Draw3DObject(srune, stiteangle, pos, stitescale, stitecolor, mat); for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = pos + (Vec3f(40.f, 0.f, 40.f) * Vec3f(frand2(), 0.f, frand2())); pd->move = Vec3f(0.8f, -4.f, 0.8f) * Vec3f(frand2(), rnd(), frand2()); pd->scale = Vec3f(-0.1f); pd->tolive = Random::get(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } Sphere sphere = Sphere(m_pos, std::max(m_level * 15.f, 50.f)); if(CheckAnythingInSphere(sphere, m_caster, CAS_NO_SAME_GROUP | CAS_NO_BACKGROUND_COL | CAS_NO_ITEM_COL| CAS_NO_FIX_COL | CAS_NO_DEAD_COL)) { ARX_BOOMS_Add(m_pos); LaunchFireballBoom(m_pos, (float)m_level); DoSphericDamage(Sphere(m_pos, 30.f * m_level), 4.f * m_level, DAMAGE_AREA, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL, m_caster); ARX_SOUND_PlaySFX(SND_SPELL_RUNE_OF_GUARDING_END, &m_pos); m_duration = 0; } }
void RepelUndeadSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); Vec3f pos = entities[m_target]->pos; float rot; if(m_target == PlayerEntityHandle) { rot = player.angle.getPitch(); } else { rot = entities[m_target]->angle.getPitch(); } m_pos = pos; m_yaw = rot; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef eObjAngle; eObjAngle.setPitch(m_yaw); eObjAngle.setYaw(0); eObjAngle.setRoll(0); float vv = 1.f + (std::sin(arxtime.get_updated() * ( 1.0f / 1000 ))); vv *= ( 1.0f / 2 ); vv += 1.1f; Draw3DObject(ssol, eObjAngle, m_pos + Vec3f(0.f, -5.f, 0.f), Vec3f(vv), Color3f(0.6f, 0.6f, 0.8f), mat); vv *= 100.f; for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } float dx = -std::sin(frand2() * 360.f) * vv; float dz = std::cos(frand2() * 360.f) * vv; pd->ov = m_pos + Vec3f(dx, 0.f, dz); pd->move = Vec3f(0.8f * frand2(), -4.f * rnd(), 0.8f * frand2()); pd->scale = Vec3f(-0.1f); pd->tolive = Random::get(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } if(!lightHandleIsValid(m_light)) { m_light = GetFreeDynLight(); } if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 2.3f; light->fallend = 350.f; light->fallstart = 150.f; light->rgb = Color3f(0.8f, 0.8f, 1.f); light->pos = m_pos + Vec3f(0.f, -50.f, 0.f); light->duration = 200; light->time_creation = (unsigned long)(arxtime); } if (m_target == PlayerEntityHandle) ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos); }
void ConfuseSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); Vec3f pos = entities[m_target]->pos; if(m_target != PlayerEntityHandle) { pos.y += entities[m_target]->physics.cyl.height - 30.f; } long idx = entities[m_target]->obj->fastaccess.head_group_origin; if(idx >= 0) { pos = entities[m_target]->obj->vertexlist3[idx].v; pos.y -= 50.f; } eCurPos = pos; RenderMaterial mat; mat.setDepthTest(false); mat.setBlendType(RenderMaterial::Additive); mat.setTexture(tex_trail); Anglef stiteangle = Anglef(0.f, -glm::degrees(arxtime.get_updated() * ( 1.0f / 500 )), 0.f); Draw3DObject(spapi, stiteangle, eCurPos, Vec3f_ONE, Color3f::white, mat); for(int i = 0; i < 6; i++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } float ang = rnd() * 360.f; float rad = rnd() * 15.f; pd->ov = eCurPos; pd->ov += angleToVectorXZ(ang) * rad; pd->move = Vec3f(0.f, rnd() * 3.f + 1.f, 0.f); pd->siz = 0.25f; pd->tolive = Random::get(2300, 3300); pd->tc = tex_p1; pd->special = PARTICLE_GOLDRAIN | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->fparam = 0.0000001f; Color3f baseColor = Color3f(0.4f, 0.2f, 0.4f); Color3f randomFactor = Color3f(0.4f, 0.6f, 0.4f); Color3f c = baseColor + Color3f(rnd(), rnd(), rnd()) * randomFactor; while(glm::abs(c.r - c.g) > 0.3f && glm::abs(c.g - c.b) > 0.3f) { c = baseColor + Color3f(rnd(), rnd(), rnd()) * randomFactor; } pd->rgb = c * Color3f(0.8f, 0.8f, 0.8f); } if(!lightHandleIsValid(m_light)) m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 1.3f; light->fallstart = 180.f; light->fallend = 420.f; light->rgb = Color3f(0.3f, 0.3f, 0.5f) + Color3f(0.2f, 0.f, 0.2f) * Color3f(rnd(), rnd(), rnd()); light->pos = eCurPos; light->duration = 200; light->extras = 0; } }
static void drawDebugPathFinding() { if(!ACTIVEBKG || !ACTIVEBKG->anchors) { return; } const float zbias = 0.00001f; for(long i = 0; i < ACTIVEBKG->nbanchors; i++) { const ANCHOR_DATA & node = ACTIVEBKG->anchors[i]; Color color1 = (node.flags & ANCHOR_FLAG_BLOCKED) ? Color::blue : Color::green; for(long j = 0; j < node.nblinked; j++) { long k = node.linked[j]; if(k >= 0 && k < ACTIVEBKG->nbanchors && i < k) { const ANCHOR_DATA & other = ACTIVEBKG->anchors[k]; Color color2 = (other.flags & ANCHOR_FLAG_BLOCKED) ? Color::blue : Color::green; drawLine(node.pos, other.pos, color1, color2, zbias); } } if(node.height != 0.f) { Vec3f toppos = node.pos + Vec3f(0.f, node.height, 0.f); drawLine(node.pos, toppos, Color::blue, zbias); } } // Highlight active paths for(size_t i = 1; i < entities.size(); i++) { const EntityHandle handle = EntityHandle(i); const Entity * entity = entities[handle]; if(!entity || !(entity->ioflags & IO_NPC)) { continue; } const IO_PATHFIND & pathfind = entity->_npcdata->pathfind; if(pathfind.listnb <= 0 || !pathfind.list) { continue; } // Draw visited nodes yellow and target nodes as red for(long j = 1; j < pathfind.listnb; j++) { short k0 = pathfind.list[j - 1], k1 = pathfind.list[j]; if(k0 >= 0 && k0 < ACTIVEBKG->nbanchors && k1 >= 0 && k1 < ACTIVEBKG->nbanchors) { const ANCHOR_DATA & n0 = ACTIVEBKG->anchors[k0], & n1 = ACTIVEBKG->anchors[k1]; Color color0 = (j <= pathfind.listpos) ? Color::yellow : Color::red; Color color1 = (j + 1 <= pathfind.listpos) ? Color::yellow : Color::red; drawLine(n0.pos, n1.pos, color0, color1, 2.f * zbias); } } // Highlight end nodes short k0 = pathfind.list[pathfind.listnb - 1]; if(k0 >= 0 && k0 < ACTIVEBKG->nbanchors) { Anglef angle(0.f, 0.f, 0.f); Vec3f scale(0.5f); RenderMaterial mat; mat.setBlendType(RenderMaterial::Opaque); mat.setDepthTest(true); Draw3DObject(g_nodeObject, angle, ACTIVEBKG->anchors[k0].pos, scale, Color3f::white, mat); } // Show entity ID at the active node if(pathfind.listpos < pathfind.listnb) { short k1 = pathfind.list[pathfind.listpos]; if(k1 >= 0 && k1 < ACTIVEBKG->nbanchors) { if(closerThan(ACTIVEBKG->anchors[k1].pos, player.pos, DebugTextMaxDistance)) { drawTextAt(hFontDebug, ACTIVEBKG->anchors[k1].pos, entity->idString()); GRenderer->SetRenderState(Renderer::DepthTest, true); } } } } }
void RuneOfGuardingSpell::Update() { EERIE_LIGHT * light = lightHandleGet(m_light); if(light) { float fa = Random::getf(0.85f, 1.0f); light->intensity = 0.7f + 2.3f * fa; light->fallend = 350.f; light->fallstart = 150.f; light->rgb = Color3f(1.0f, 0.2f, 0.2f); light->creationTime = g_gameTime.now(); light->duration = GameDurationMs(200); } Vec3f pos = m_pos + Vec3f(0.f, -20.f, 0.f); RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef stiteangle; Color3f stitecolor; float stiteangleb = m_elapsed / GameDurationMs(100); stiteangle.setPitch(0); stiteangle.setRoll(0); stiteangle.setYaw(stiteangleb * 0.1f); stitecolor = Color3f(0.4f, 0.4f, 0.6f); float scale = std::sin(m_elapsed / GameDurationMsf(66.6666666f)); Vec3f stitescale = Vec3f(1.f, -0.1f, 1.f); Draw3DObject(slight, stiteangle, pos, stitescale, stitecolor, mat); stiteangle.setYaw(stiteangleb); stitecolor = Color3f(0.6f, 0.f, 0.f); stitescale = Vec3f(2.f) * (1.f + 0.01f * scale); Draw3DObject(ssol, stiteangle, pos, stitescale, stitecolor, mat); stitecolor = Color3f(0.6f, 0.3f, 0.45f); stitescale = Vec3f(1.8f) * (1.f + 0.02f * scale); Draw3DObject(srune, stiteangle, pos, stitescale, stitecolor, mat); for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = pos + arx::randomOffsetXZ(40.f); pd->move = arx::linearRand(Vec3f(-0.8f, -4.f, -0.8f), Vec3f(0.8f, 0.f, 0.8f)); pd->scale = Vec3f(-0.1f); pd->tolive = Random::getu(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } Sphere sphere = Sphere(m_pos, std::max(m_level * 15.f, 50.f)); if(CheckAnythingInSphere(sphere, m_caster, CAS_NO_SAME_GROUP | CAS_NO_BACKGROUND_COL | CAS_NO_ITEM_COL | CAS_NO_FIX_COL | CAS_NO_DEAD_COL)) { spawnFireHitParticle(m_pos, 0); PolyBoomAddScorch(m_pos); LaunchFireballBoom(m_pos, m_level); DoSphericDamage(Sphere(m_pos, 30.f * m_level), 4.f * m_level, DAMAGE_AREA, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL, m_caster); ARX_SOUND_PlaySFX(g_snd.SPELL_RUNE_OF_GUARDING_END, &m_pos); requestEnd(); } }
void CMagicMissile::Render() { Vec3f lastpos, newpos; Vec3f v; if(ulCurrentTime >= ulDuration) return; RenderMaterial mat; mat.setCulling(Renderer::CullNone); mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); if(tex_mm) mat.setTexture(tex_mm); if(bMove) { float fOneOnDuration = 1.f / (float)(ulDuration); fTrail = (ulCurrentTime * fOneOnDuration) * (iBezierPrecision + 2) * 5; } newpos = lastpos = pathways[0]; for(int i = 0; i < 5; i++) { int kp = i; int kpprec = (i > 0) ? kp - 1 : kp ; int kpsuiv = kp + 1 ; int kpsuivsuiv = (i < (5 - 2)) ? kpsuiv + 1 : kpsuiv; for(int toto = 1; toto < iBezierPrecision; toto++) { if(fTrail < i * iBezierPrecision + toto) break; float t = toto * fOneOnBezierPrecision; float t1 = t; float t2 = t1 * t1 ; float t3 = t2 * t1 ; float f0 = 2.f * t3 - 3.f * t2 + 1.f ; float f1 = -2.f * t3 + 3.f * t2 ; float f2 = t3 - 2.f * t2 + t1 ; float f3 = t3 - t2 ; float val = pathways[kpsuiv].x; float p0 = 0.5f * (val - pathways[kpprec].x) ; float p1 = 0.5f * (pathways[kpsuivsuiv].x - pathways[kp].x) ; v.x = f0 * pathways[kp].x + f1 * val + f2 * p0 + f3 * p1 ; val = pathways[kpsuiv].y ; p0 = 0.5f * (val - pathways[kpprec].y) ; p1 = 0.5f * (pathways[kpsuivsuiv].y - pathways[kp].y) ; v.y = f0 * pathways[kp].y + f1 * val + f2 * p0 + f3 * p1 ; val = pathways[kpsuiv].z ; p0 = 0.5f * (val - pathways[kpprec].z) ; p1 = 0.5f * (pathways[kpsuivsuiv].z - pathways[kp].z) ; v.z = f0 * pathways[kp].z + f1 * val + f2 * p0 + f3 * p1 ; newpos = v; if(!((fTrail - (i * iBezierPrecision + toto)) > iLength)) { float c; if(fTrail < iLength) { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / fTrail); } else { c = 1.0f - ((fTrail - (i * iBezierPrecision + toto)) / (float)iLength); } float fsize = c; float alpha = c - 0.2f; if(alpha < 0.2f) alpha = 0.2f; c += Random::getf(-0.1f, 0.1f); c = glm::clamp(c, 0.f, 1.f); Color color = (m_trailColor * (c * alpha)).to<u8>(); if(fsize < 0.5f) fsize = fsize * 2 * 3; else fsize = (1.0f - fsize + 0.5f) * 2 * (3 * 0.5f); float fs = fsize * 6 + Random::getf(0.f, 0.3f); float fe = fsize * 6 + Random::getf(0.f, 0.3f); Draw3DLineTexNew(mat, lastpos, newpos, color, color, fs, fe); } Vec3f temp_vector = lastpos; lastpos = newpos; newpos = temp_vector; } } Vec3f av = newpos - lastpos; float bubu = getAngle(av.x, av.z, 0, 0); float bubu1 = getAngle(av.x, av.y, 0, 0); eCurPos = lastpos; Anglef stiteangle; stiteangle.setPitch(-glm::degrees(bubu)); stiteangle.setYaw(0); stiteangle.setRoll(-(glm::degrees(bubu1))); if(av.x < 0) stiteangle.setRoll(stiteangle.getRoll() - 90); if(av.x > 0) stiteangle.setRoll(stiteangle.getRoll() + 90); if(stiteangle.getRoll() < 0) stiteangle.setRoll(stiteangle.getRoll() + 360.0f); Draw3DObject(smissile, stiteangle, eCurPos, Vec3f_ONE, m_projectileColor, mat); }
void RepelUndeadSpell::Update() { Vec3f pos = entities[m_target]->pos; float rot; if(m_target == EntityHandle_Player) { rot = player.angle.getYaw(); } else { rot = entities[m_target]->angle.getYaw(); } m_pos = pos; m_yaw = rot; RenderMaterial mat; mat.setDepthTest(true); mat.setBlendType(RenderMaterial::Additive); Anglef eObjAngle; eObjAngle.setYaw(m_yaw); eObjAngle.setPitch(0); eObjAngle.setRoll(0); float wave = timeWaveSin(g_gameTime.now(), GameDurationMsf(6283.185307f)); float vv = (1.f + wave) * 0.5f + 1.1f; Draw3DObject(ssol, eObjAngle, m_pos + Vec3f(0.f, -5.f, 0.f), Vec3f(vv), Color3f(0.6f, 0.6f, 0.8f), mat); vv *= 100.f; for(int n = 0; n < 4; n++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } // XXX was this supposed to be sphericalRand ? Vec2f d = arx::diskRand(vv); pd->ov = m_pos + Vec3f(d.x, 0.f, d.y); pd->move = arx::linearRand(Vec3f(-0.8f, -4.f, -0.8f), Vec3f(0.8f, 0.f, 0.8f)); pd->scale = Vec3f(-0.1f); pd->tolive = Random::getu(2600, 3200); pd->tc = tex_p2; pd->siz = 0.3f; pd->rgb = Color3f(.4f, .4f, .6f); } EERIE_LIGHT * light = dynLightCreate(m_light); if(light) { light->intensity = 2.3f; light->fallend = 350.f; light->fallstart = 150.f; light->rgb = Color3f(0.8f, 0.8f, 1.f); light->pos = m_pos + Vec3f(0.f, -50.f, 0.f); light->duration = GameDurationMs(200); light->creationTime = g_gameTime.now(); } if (m_target == EntityHandle_Player) ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos); }