void SummonCreatureSpell::Launch() { m_hasDuration = true; m_fManaCostPerSecond = 1.9f; m_requestSummon = false; m_summonedEntity = EntityHandle(); m_duration = (m_launchDuration > -1) ? m_launchDuration : 2000000; Vec3f target; float beta; GetTargetAndBeta(target, beta); m_megaCheat = (m_caster == PlayerEntityHandle && cur_mega == 10); m_targetPos = target; ARX_SOUND_PlaySFX(SND_SPELL_SUMMON_CREATURE, &m_targetPos); m_fissure.Create(target, MAKEANGLE(player.angle.getPitch())); m_fissure.SetDuration(2000, 500, 1500); m_fissure.SetColorBorder(Color3f::red); m_fissure.SetColorRays1(Color3f::red); m_fissure.SetColorRays2(Color3f::yellow * .5f); m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 0.3f; light->fallend = 500.f; light->fallstart = 400.f; light->rgb = Color3f::red; light->pos = m_fissure.m_eSrc; } }
void RuneOfGuardingSpell::Launch() { spells.endByCaster(m_caster, SPELL_RUNE_OF_GUARDING); ARX_SOUND_PlaySFX(SND_SPELL_RUNE_OF_GUARDING); m_duration = (m_launchDuration > -1) ? m_launchDuration : 99999999; m_pos = entities[m_caster]->pos; tex_p2 = TextureContainer::Load("graph/obj3d/textures/(fx)_tsu_blueting"); m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 0.7f + 2.3f; light->fallend = 500.f; light->fallstart = 400.f; light->rgb = Color3f(1.0f, 0.2f, 0.2f); light->pos = m_pos - Vec3f(0.f, 50.f, 0.f); light->time_creation = (unsigned long)(arxtime); light->duration = 200; } }
void SummonCreatureSpell::End() { lightHandleDestroy(m_light); // need to killio if(ValidIONum(m_summonedEntity)) { Entity * io = entities[m_summonedEntity]; ARX_SOUND_PlaySFX(SND_SPELL_ELECTRIC, &io->pos); if(io->scriptload && (io->ioflags & IO_NOSAVE)) { AddRandomSmoke(io, 100); Vec3f posi = io->pos; posi.y -= 100.f; MakeCoolFx(posi); LightHandle nn = GetFreeDynLight(); if(lightHandleIsValid(nn)) { EERIE_LIGHT * light = lightHandleGet(nn); light->intensity = Random::getf(0.7f, 2.7f); light->fallend = 600.f; light->fallstart = 400.f; light->rgb = Color3f(1.0f, 0.8f, 0.0f); light->pos = posi; light->duration = 600; } io->destroyOne(); } } m_summonedEntity = EntityHandle(); }
EERIE_LIGHT * dynLightCreate(LightHandle & handle) { if(!lightHandleGet(handle)) { handle = GetFreeDynLight(); } return lightHandleGet(handle); }
//----------------------------------------------------------------------------- void CIgnit::AddLight(int aiLight) { if (ARXPausedTimer) return; if (this->nblight > 255) return; this->tablight[this->nblight].actif = 1; this->tablight[this->nblight].iLightNum = aiLight; this->tablight[this->nblight].poslight.x = GLight[aiLight]->pos.x; this->tablight[this->nblight].poslight.y = GLight[aiLight]->pos.y; this->tablight[this->nblight].poslight.z = GLight[aiLight]->pos.z; this->tablight[this->nblight].idl = GetFreeDynLight(); if (this->tablight[this->nblight].idl > 0) { int id = this->tablight[this->nblight].idl; EERIE_LIGHT * el = &DynLight[id]; el->exist = 1; el->intensity = 0.7f + 2.f * rnd(); el->fallend = 400.f; el->fallstart = 300.f; el->rgb.r = this->r; el->rgb.g = this->g; el->rgb.b = this->b; el->pos.x = this->tablight[this->nblight].poslight.x; el->pos.y = this->tablight[this->nblight].poslight.y; el->pos.z = this->tablight[this->nblight].poslight.z; } this->nblight++; }
void FakeSummonSpell::Launch() { m_hasDuration = true; m_fManaCostPerSecond = 1.9f; m_duration = 4000; Vec3f target = entities[m_target]->pos; if(m_target != PlayerEntityHandle) { target.y += player.baseHeight(); } m_targetPos = target; ARX_SOUND_PlaySFX(SND_SPELL_SUMMON_CREATURE, &m_targetPos); m_fissure.Create(target, MAKEANGLE(player.angle.getPitch())); m_fissure.SetDuration(2000, 500, 1500); m_fissure.SetColorBorder(Color3f::red); m_fissure.SetColorRays1(Color3f::red); m_fissure.SetColorRays2(Color3f::yellow * .5f); m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 0.3f; light->fallend = 500.f; light->fallstart = 400.f; light->rgb = Color3f::red; light->pos = m_fissure.m_eSrc; } }
void RiseDeadSpell::End() { if(ValidIONum(m_entity)) { Entity *entity = entities[m_entity]; ARX_SOUND_PlaySFX(SND_SPELL_ELECTRIC, &entity->pos); if(entity->scriptload && (entity->ioflags & IO_NOSAVE)) { AddRandomSmoke(entity,100); Vec3f posi = entity->pos; posi.y-=100.f; MakeCoolFx(posi); LightHandle nn = GetFreeDynLight(); if(lightHandleIsValid(nn)) { EERIE_LIGHT * light = lightHandleGet(nn); light->intensity = Random::getf(0.7f, 2.7f); light->fallend = 600.f; light->fallstart = 400.f; light->rgb = Color3f(1.0f, 0.8f, 0.f); light->pos = posi; light->duration = 600; } entity->destroyOne(); } } endLightDelayed(m_light, 500); }
void CMultiPoisonProjectile::Create(Vec3f srcPos, float afBeta) { long lMax = 0; for(size_t i = 0; i < m_projectiles.size(); i++) { CPoisonProjectile * projectile = m_projectiles[i]; projectile->Create(srcPos, afBeta + frand2() * 10.0f); long lTime = ulDuration + Random::get(0, 5000); projectile->SetDuration(lTime); lMax = std::max(lMax, lTime); projectile->lLightId = GetFreeDynLight(); if(lightHandleIsValid(projectile->lLightId)) { EERIE_LIGHT * light = lightHandleGet(projectile->lLightId); light->intensity = 2.3f; light->fallend = 250.f; light->fallstart = 150.f; light->rgb = Color3f::green; light->pos = projectile->eSrc; light->time_creation = (unsigned long)(arxtime); light->duration = 200; } } SetDuration(lMax + 1000); }
static void CheckExp(long i) { if((Thrown[i].flags & ATO_FIERY) && !(Thrown[i].flags & ATO_UNDERWATER)) { const Vec3f & pos = Thrown[i].position; ARX_BOOMS_Add(pos); LaunchFireballBoom(pos, 10); DoSphericDamage(Sphere(pos, 50.f), 4.f * 2, DAMAGE_AREA, DAMAGE_TYPE_FIRE | DAMAGE_TYPE_MAGICAL, PlayerEntityHandle); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_HIT, &pos); ARX_NPC_SpawnAudibleSound(pos, entities.player()); LightHandle id = GetFreeDynLight(); if(lightHandleIsValid(id) && framedelay > 0) { EERIE_LIGHT * light = lightHandleGet(id); light->intensity = 3.9f; light->fallstart = 400.f; light->fallend = 440.f; light->rgb = Color3f(1.f, .8f, .6f) - randomColor3f() * Color3f(.2f, .2f, .2f); light->pos = pos; light->ex_flaresize = 40.f; light->duration = 1500; } } }
void FireFieldSpell::Update(float timeDelta) { pPSStream.Update(timeDelta); pPSStream1.Update(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(1.f, 0.8f, 0.6f) - Color3f(rnd()*(1.0f/10), 0.f, 0.f); el->duration = 600; el->extras=0; } if(VisibleSphere(Sphere(m_pos - Vec3f(0.f, 120.f, 0.f), 350.f))) { pPSStream.Render(); pPSStream1.Render(); float fDiff = timeDelta / 8.f; int nTime = checked_range_cast<int>(fDiff); for(long nn=0;nn<=nTime+1;nn++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } float t = rnd() * (PI * 2.f) - PI; float ts = std::sin(t); float tc = std::cos(t); pd->ov = m_pos + Vec3f(120.f * ts, 15.f * ts, 120.f * tc) * randomVec(); pd->move = Vec3f(2.f, 1.f, 2.f) + Vec3f(-4.f, -8.f, -4.f) * Vec3f(rnd(), rnd(), rnd()); pd->siz = 7.f; pd->tolive = Random::get(500, 1500); pd->tc = fire2; pd->special = ROTATING | MODULATE_ROTATION | FIRE_TO_SMOKE; pd->fparam = 0.1f - rnd() * 0.2f; pd->scale = Vec3f(-8.f); PARTICLE_DEF * pd2 = createParticle(); if(!pd2) { break; } *pd2 = *pd; pd2->delay = Random::get(60, 210); } } }
void MassLightningStrikeSpell::Launch() { spells.endByType(SPELL_MASS_LIGHTNING_STRIKE); m_duration = 5000; // TODO probably never read m_soundEffectPlayed = false; float beta; if(m_caster == PlayerEntityHandle) { m_pos = player.pos + Vec3f(0.f, 150.f, 0.f); beta = player.angle.getPitch(); } else { Entity * io = entities[m_caster]; m_pos = io->pos + Vec3f(0.f, -20.f, 0.f); beta = io->angle.getPitch(); } m_pos += angleToVectorXZ(beta) * 500.f; long minDuration = long(500 * m_level); long maxDuration = 0; int number = glm::clamp(int(m_level), 1, 10); float ft = 360.0f / (float)number; for(int i = 0; i < number; i++) { Vec3f target = m_pos + angleToVectorXZ(i * ft) * 500.0f; long duration = minDuration + Random::get(0, 5000); maxDuration = std::max(maxDuration, duration); CLightning * lightning = new CLightning(); lightning->m_isMassLightning = true; lightning->m_fDamage = 2; lightning->Create(m_pos, target); lightning->SetDuration(duration); pTab.push_back(lightning); } m_duration = maxDuration + 1000; m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 1.8f; light->fallend = 850.f; light->fallstart = 500.f; light->rgb = Color3f::red; // Color3f(1.f, 0.75f, 0.75f); light->pos = m_pos; } ARX_SOUND_PlaySFX(SND_SPELL_LIGHTNING_START); m_snd_loop = ARX_SOUND_PlaySFX(SND_SPELL_LIGHTNING_LOOP, &m_pos, 1.f, ARX_SOUND_PLAY_LOOPED); // Draws White Flash on Screen GRenderer->SetBlendFunc(BlendOne, BlendOne); GRenderer->SetRenderState(Renderer::AlphaBlending, true); EERIEDrawBitmap(Rectf(g_size), 0.00009f, NULL, Color::white); GRenderer->SetRenderState(Renderer::AlphaBlending, false); }
void CMultiMagicMissile::Create(Vec3f aePos, float afAlpha, float afBeta) { long lMax = 0; for(size_t i = 0; i < pTab.size(); i++) { Anglef angles(afAlpha, afBeta, 0.f); if(i > 0) { angles.setYaw(angles.getYaw() + frand2() * 4.0f); angles.setPitch(angles.getPitch() + frand2() * 6.0f); } pTab[i]->Create(aePos, angles); float fTime = ulDuration + frand2() * 1000.0f; long lTime = checked_range_cast<long>(fTime); lTime = std::max(1000L, lTime); lMax = std::max(lMax, lTime); CMagicMissile * pMM = (CMagicMissile *)pTab[i]; pMM->SetDuration(lTime); if(m_mrCheat) { pMM->SetColor(Color3f(0.9f, 0.2f, 0.5f)); } else { pMM->SetColor(Color3f(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f)); } pTab[i]->lLightId = GetFreeDynLight(); if(lightHandleIsValid(pTab[i]->lLightId)) { EERIE_LIGHT * el = lightHandleGet(pTab[i]->lLightId); el->intensity = 0.7f + 2.3f; el->fallend = 190.f; el->fallstart = 80.f; if(m_mrCheat) { el->rgb.r = 1; el->rgb.g = 0.3f; el->rgb.b = 0.8f; } else { el->rgb.r = 0; el->rgb.g = 0; el->rgb.b = 1; } el->pos = pMM->eSrc; el->duration = 300; } } SetDuration(lMax + 1000); }
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 CurePoisonSpell::Update(float timeDelta) { ulCurrentTime += timeDelta; m_pos = entities[m_target]->pos; if(m_target == PlayerEntityHandle) m_pos.y += 200; unsigned long ulCalc = m_duration - ulCurrentTime ; arx_assert(ulCalc <= LONG_MAX); long ff = static_cast<long>(ulCalc); if(ff < 1500) { pPS.m_parameters.m_spawnFlags = PARTICLE_CIRCULAR; pPS.m_parameters.m_gravity = Vec3f_ZERO; std::list<Particle *>::iterator i; for(i = pPS.listParticle.begin(); i != pPS.listParticle.end(); ++i) { Particle * pP = *i; if(pP->isAlive()) { pP->fColorEnd.a = 0; if(pP->m_age + ff < pP->m_timeToLive) { pP->m_age = pP->m_timeToLive - ff; } } } } pPS.SetPos(m_pos); pPS.Update(timeDelta); if(!lightHandleIsValid(m_light)) m_light = GetFreeDynLight(); if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 2.3f; light->fallstart = 200.f; light->fallend = 350.f; light->rgb = Color3f(0.4f, 1.f, 0.4f); light->pos = m_pos + Vec3f(0.f, -50.f, 0.f); light->duration = 200; light->time_creation = (unsigned long)(arxtime); light->extras = 0; } pPS.Render(); }
void CCurePoison::Update(float timeDelta) { ulCurrentTime += timeDelta; if(ulCurrentTime >= ulDuration) return; unsigned long ulCalc = ulDuration - ulCurrentTime ; arx_assert(ulCalc <= LONG_MAX); long ff = static_cast<long>(ulCalc); if(ff < 1500) { pPS->m_parameters.m_spawnFlags = PARTICLE_CIRCULAR; pPS->m_parameters.m_gravity = Vec3f_ZERO; std::list<Particle *>::iterator i; for(i = pPS->listParticle.begin(); i != pPS->listParticle.end(); ++i) { Particle * pP = *i; if(pP->isAlive()) { pP->fColorEnd.a = 0; if(pP->m_age + ff < pP->m_timeToLive) { pP->m_age = pP->m_timeToLive - ff; } } } } pPS->SetPos(eSrc); pPS->Update(timeDelta); if(!lightHandleIsValid(pPS->m_lightHandle)) pPS->m_lightHandle = GetFreeDynLight(); if(lightHandleIsValid(pPS->m_lightHandle)) { EERIE_LIGHT * light = lightHandleGet(pPS->m_lightHandle); light->intensity = 2.3f; light->fallstart = 200.f; light->fallend = 350.f; light->rgb = Color3f(0.4f, 1.f, 0.4f); light->pos = eSrc + Vec3f(0.f, -50.f, 0.f); light->duration = 200; light->time_creation = (unsigned long)(arxtime); light->extras = 0; } }
//----------------------------------------------------------------------------- // Spawns a Projectile using type, starting position/TargetPosition void ARX_MISSILES_Spawn(INTERACTIVE_OBJ *io, const long &type, const EERIE_3D *startpos, const EERIE_3D *targetpos) { long i(ARX_MISSILES_GetFree()); if (i == -1) return; missiles[i].owner = GetInterNum(io); missiles[i].type = type; missiles[i].lastpos.x = missiles[i].startpos.x = startpos->x; missiles[i].lastpos.y = missiles[i].startpos.y = startpos->y; missiles[i].lastpos.z = missiles[i].startpos.z = startpos->z; float dist; dist = 1.0F / Distance3D(startpos->x, startpos->y, startpos->z, targetpos->x, targetpos->y,targetpos->z); missiles[i].velocity.x = (targetpos->x - startpos->x) * dist; missiles[i].velocity.y = (targetpos->y - startpos->y) * dist; missiles[i].velocity.z = (targetpos->z - startpos->z) * dist; missiles[i].lastupdate = missiles[i].timecreation = ARXTimeUL(); switch (type) { case MISSILE_FIREBALL: { missiles[i].tolive = 6000; missiles[i].velocity.x *= 0.8f; missiles[i].velocity.y *= 0.8f; missiles[i].velocity.z *= 0.8f; missiles[i].longinfo = GetFreeDynLight(); if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].intensity = 1.3f; DynLight[missiles[i].longinfo].exist = 1; DynLight[missiles[i].longinfo].fallend = 420.f; DynLight[missiles[i].longinfo].fallstart = 250.f; DynLight[missiles[i].longinfo].rgb.r = 1.f; DynLight[missiles[i].longinfo].rgb.g = 0.8f; DynLight[missiles[i].longinfo].rgb.b = 0.6f; DynLight[missiles[i].longinfo].pos.x = startpos->x; DynLight[missiles[i].longinfo].pos.y = startpos->y; DynLight[missiles[i].longinfo].pos.z = startpos->z; } ARX_SOUND_PlaySFX(SND_SPELL_FIRE_WIND, &missiles[i].startpos, 2.0F); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_LAUNCH, &missiles[i].startpos, 2.0F); } } }
void CHeal::Create() { pPS->m_lightHandle = GetFreeDynLight(); if(lightHandleIsValid(pPS->m_lightHandle)) { EERIE_LIGHT * light = lightHandleGet(pPS->m_lightHandle); light->intensity = 2.3f; light->fallstart = 200.f; light->fallend = 350.f; light->rgb = Color3f(0.4f, 0.4f, 1.0f); light->pos = eSrc + Vec3f(0.f, -50.f, 0.f); light->duration = 200; light->extras = 0; } pPS->SetPos(eSrc); ParticleParams cp = ParticleParams(); cp.m_nbMax = 350; cp.m_life = 800; cp.m_lifeRandom = 2000; cp.m_pos = Vec3f(100, 200, 100); cp.m_direction = Vec3f(0, -10, 0) * 0.1f; cp.m_angle = glm::radians(5.f); cp.m_speed = 120; cp.m_speedRandom = 84; cp.m_gravity = Vec3f(0, -10, 0); cp.m_flash = 0; cp.m_rotation = 1.0f / (101 - 80); cp.m_startSegment.m_size = 8; cp.m_startSegment.m_sizeRandom = 8; cp.m_startSegment.m_color = Color(205, 205, 255, 245).to<float>(); cp.m_startSegment.m_colorRandom = Color(50, 50, 0, 10).to<float>(); cp.m_endSegment.m_size = 6; cp.m_endSegment.m_sizeRandom = 4; cp.m_endSegment.m_color = Color(20, 20, 30, 0).to<float>(); cp.m_endSegment.m_colorRandom = Color(0, 0, 40, 0).to<float>(); cp.m_blendMode = RenderMaterial::Additive; cp.m_texture.set("graph/particles/heal_0005", 0, 100); cp.m_spawnFlags = PARTICLE_CIRCULAR | PARTICLE_BORDER; pPS->SetParams(cp); }
void RiseDeadSpell::Launch() { float beta; Vec3f target; GetTargetAndBeta(target, beta); m_targetPos = target; ARX_SOUND_PlaySFX(SND_SPELL_RAISE_DEAD, &m_targetPos); // TODO this tolive value is probably never read m_duration = (m_launchDuration > -1) ? m_launchDuration : 2000000; m_hasDuration = true; m_fManaCostPerSecond = 1.2f; m_creationFailed = false; m_entity = EntityHandle(); m_fissure.Create(target, beta); m_fissure.SetDuration(2000, 500, 1800); m_fissure.SetColorBorder(Color3f(0.5, 0.5, 0.5)); m_fissure.SetColorRays1(Color3f(0.5, 0.5, 0.5)); m_fissure.SetColorRays2(Color3f(1.f, 0.f, 0.f)); if(!lightHandleIsValid(m_light)) { m_light = GetFreeDynLight(); } if(lightHandleIsValid(m_light)) { EERIE_LIGHT * light = lightHandleGet(m_light); light->intensity = 1.3f; light->fallend = 450.f; light->fallstart = 380.f; light->rgb = Color3f::black; light->pos = target - Vec3f(0.f, 100.f, 0.f); light->duration = 200; light->time_creation = (unsigned long)(arxtime); } m_duration = m_fissure.GetDuration(); }
static void LaunchMagicMissileExplosion(const Vec3f & _ePos, bool mrCheat) { ParticleParams cp = MagicMissileExplosionParticle(); if(mrCheat) { cp = MagicMissileExplosionMrCheatParticle(); } ParticleSystem * pPS = new ParticleSystem(); pPS->SetParams(cp); pPS->SetPos(_ePos); pPS->Update(0); LightHandle id = GetFreeDynLight(); if(lightHandleIsValid(id)) { EERIE_LIGHT * light = lightHandleGet(id); light->intensity = 2.3f; light->fallstart = 250.f; light->fallend = 420.f; if(mrCheat) { light->rgb.r = 1.f; light->rgb.g = 0.3f; light->rgb.b = .8f; } else { light->rgb.r = 0.f; light->rgb.g = 0.f; light->rgb.b = .8f; } light->pos = _ePos; light->duration = 1500; } arx_assert(pParticleManager); pParticleManager->AddSystem(pPS); ARX_SOUND_PlaySFX(SND_SPELL_MM_HIT, &_ePos); }
void CRuneOfGuarding::Create(Vec3f _eSrc) { SetDuration(ulDuration); eSrc = _eSrc; eTarget = eSrc; lLightId = GetFreeDynLight(); if(lightHandleIsValid(lLightId)) { EERIE_LIGHT * light = lightHandleGet(lLightId); light->intensity = 0.7f + 2.3f; light->fallend = 500.f; light->fallstart = 400.f; light->rgb.r = 1.0f; light->rgb.g = 0.2f; light->rgb.b = 0.2f; light->pos = eSrc - Vec3f(0.f, 50.f, 0.f); light->time_creation = (unsigned long)(arxtime); light->duration = 200; } }
//----------------------------------------------------------------------------- // Spawns a Projectile using type, starting position/TargetPosition void ARX_MISSILES_Spawn(Entity * io, ARX_SPELLS_MISSILE_TYPE type, const Vec3f * startpos, const Vec3f * targetpos) { long i(ARX_MISSILES_GetFree()); if (i == -1) return; missiles[i].owner = (io == NULL) ? -1 : io->index(); missiles[i].type = type; missiles[i].lastpos = missiles[i].startpos = *startpos; float dist; dist = 1.0F / fdist(*startpos, *targetpos); missiles[i].velocity = (*targetpos - *startpos) * dist; missiles[i].lastupdate = missiles[i].timecreation = (unsigned long)(arxtime); switch (type) { case MISSILE_NONE: break; case MISSILE_FIREBALL: { missiles[i].tolive = 6000; missiles[i].velocity *= 0.8f; missiles[i].longinfo = GetFreeDynLight(); if (missiles[i].longinfo != -1) { DynLight[missiles[i].longinfo].intensity = 1.3f; DynLight[missiles[i].longinfo].exist = 1; DynLight[missiles[i].longinfo].fallend = 420.f; DynLight[missiles[i].longinfo].fallstart = 250.f; DynLight[missiles[i].longinfo].rgb = Color3f(1.f, .8f, .6f); DynLight[missiles[i].longinfo].pos = *startpos; } ARX_SOUND_PlaySFX(SND_SPELL_FIRE_WIND, &missiles[i].startpos, 2.0F); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_LAUNCH, &missiles[i].startpos, 2.0F); } } }
//----------------------------------------------------------------------------- // Spawns a Projectile using type, starting position/TargetPosition void ARX_MISSILES_Spawn(Entity * io, ARX_SPELLS_MISSILE_TYPE type, const Vec3f & startpos, const Vec3f & targetpos) { long i(ARX_MISSILES_GetFree()); if (i == -1) return; missiles[i].owner = (io == NULL) ? EntityHandle::Invalid : io->index(); missiles[i].type = type; missiles[i].lastpos = missiles[i].startpos = startpos; float dist; dist = 1.0F / fdist(startpos, targetpos); missiles[i].velocity = (targetpos - startpos) * dist; missiles[i].lastupdate = missiles[i].timecreation = (unsigned long)(arxtime); switch (type) { case MISSILE_NONE: break; case MISSILE_FIREBALL: { missiles[i].tolive = 6000; missiles[i].velocity *= 0.8f; missiles[i].longinfo = GetFreeDynLight(); if(lightHandleIsValid(missiles[i].longinfo)) { EERIE_LIGHT * light = lightHandleGet(missiles[i].longinfo); light->intensity = 1.3f; light->fallend = 420.f; light->fallstart = 250.f; light->rgb = Color3f(1.f, .8f, .6f); light->pos = startpos; } ARX_SOUND_PlaySFX(SND_SPELL_FIRE_WIND, &missiles[i].startpos, 2.0F); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_LAUNCH, &missiles[i].startpos, 2.0F); } } }
void CIgnit::AddLight(int aiLight) { if(arxtime.is_paused()) return; this->tablight[this->nblight].actif = 1; this->tablight[this->nblight].iLightNum = aiLight; this->tablight[this->nblight].poslight = GLight[aiLight]->pos; this->tablight[this->nblight].idl = GetFreeDynLight(); if(this->tablight[this->nblight].idl > 0) { int id = this->tablight[this->nblight].idl; EERIE_LIGHT * el = &DynLight[id]; el->exist = 1; el->intensity = 0.7f + 2.f * rnd(); el->fallend = 400.f; el->fallstart = 300.f; el->rgb = rgb; el->pos = this->tablight[this->nblight].poslight; } this->nblight++; }
//----------------------------------------------------------------------------- void CRuneOfGuarding::Create(EERIE_3D _eSrc, float _fBeta) { SetDuration(ulDuration); SetAngle(_fBeta); eSrc.x = _eSrc.x; eSrc.y = _eSrc.y; eSrc.z = _eSrc.z; eTarget.x = eSrc.x; eTarget.y = eSrc.y; eTarget.z = eSrc.z; fSize = 1; bDone = true; lLightId = GetFreeDynLight(); if (lLightId != -1) { long id = lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 0.7f + 2.3f; DynLight[id].fallend = 500.f; DynLight[id].fallstart = 400.f; DynLight[id].rgb.r = 1.0f; DynLight[id].rgb.g = 0.2f; DynLight[id].rgb.b = 0.2f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50; DynLight[id].pos.z = eSrc.z; DynLight[id].time_creation = ARXTimeUL(); DynLight[id].duration = 200; } }
void CRuneOfGuarding::Create(Vec3f _eSrc, float _fBeta) { SetDuration(ulDuration); SetAngle(_fBeta); eSrc = _eSrc; eTarget = eSrc; fSize = 1; bDone = true; lLightId = GetFreeDynLight(); if(lLightId != -1) { long id = lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 0.7f + 2.3f; DynLight[id].fallend = 500.f; DynLight[id].fallstart = 400.f; DynLight[id].rgb.r = 1.0f; DynLight[id].rgb.g = 0.2f; DynLight[id].rgb.b = 0.2f; DynLight[id].pos = eSrc - Vec3f(0.f, 50.f, 0.f); DynLight[id].time_creation = (unsigned long)(arxtime); DynLight[id].duration = 200; } }
//----------------------------------------------------------------------------- void CHeal::Create() { SetAngle(MAKEANGLE(player.angle.b)); if (spells[spellinstance].caster == 0) { eSrc.x = player.pos.x; eSrc.y = player.pos.y; eSrc.z = player.pos.z; } else { eSrc.x = inter.iobj[spells[spellinstance].caster]->pos.x; eSrc.y = inter.iobj[spells[spellinstance].caster]->pos.y; eSrc.z = inter.iobj[spells[spellinstance].caster]->pos.z; } pPS->lLightId = GetFreeDynLight(); if (pPS->lLightId != -1) { long id = pPS->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f; DynLight[id].fallstart = 200.f; DynLight[id].fallend = 350.f; DynLight[id].rgb.r = 0.4f; DynLight[id].rgb.g = 0.4f; DynLight[id].rgb.b = 1.0f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50.f; DynLight[id].pos.z = eSrc.z; DynLight[id].duration = 200; DynLight[id].extras = 0; } pPS->SetPos(eSrc); CParticleParams cp; cp.iNbMax = 350; cp.fLife = 800; cp.fLifeRandom = 2000; cp.p3Pos.x = 100; cp.p3Pos.y = 200; cp.p3Pos.z = 100; cp.p3Direction.x = 0; cp.p3Direction.y = -10; cp.p3Direction.z = 0; cp.fAngle = DEG2RAD(5); cp.fSpeed = 120; cp.fSpeedRandom = 84; cp.p3Gravity.x = 0; cp.p3Gravity.y = -10; cp.p3Gravity.z = 0; cp.fFlash = 0; cp.fRotation = 80; cp.fStartSize = 8; cp.fStartSizeRandom = 8; cp.fStartColor[0] = 205; cp.fStartColor[1] = 205; cp.fStartColor[2] = 255; cp.fStartColor[3] = 245; cp.fStartColorRandom[0] = 50; cp.fStartColorRandom[1] = 50; cp.fStartColorRandom[2] = 0; cp.fStartColorRandom[3] = 10; cp.fEndSize = 6; cp.fEndSizeRandom = 4; cp.fEndColor[0] = 20; cp.fEndColor[1] = 20; cp.fEndColor[2] = 30; cp.fEndColor[3] = 0; cp.fEndColorRandom[0] = 0; cp.fEndColorRandom[1] = 0; cp.fEndColorRandom[2] = 40; cp.fEndColorRandom[3] = 0; pPS->SetParams(cp); pPS->ulParticleSpawn = PARTICLE_CIRCULAR | PARTICLE_BORDER; pPS->SetTexture("graph\\particles\\heal_0005.bmp", 0, 100); fSize = 1; }
//--------------------------------------------------------------------- void CHeal::Update(unsigned long aulTime) { ulCurrentTime += aulTime; if (ulCurrentTime >= ulDuration) { return; } if (spells[spellinstance].caster == 0) { eSrc.x = player.pos.x; eSrc.y = player.pos.y; eSrc.z = player.pos.z; } else { if (ValidIONum(spells[spellinstance].target)) { eSrc.x = inter.iobj[spells[spellinstance].target]->pos.x; eSrc.y = inter.iobj[spells[spellinstance].target]->pos.y; eSrc.z = inter.iobj[spells[spellinstance].target]->pos.z; } } if (pPS->lLightId == -1) pPS->lLightId = GetFreeDynLight(); if (pPS->lLightId != -1) { long id = pPS->lLightId; DynLight[id].exist = 1; DynLight[id].intensity = 2.3f; DynLight[id].fallstart = 200.f; DynLight[id].fallend = 350.f; DynLight[id].rgb.r = 0.4f; DynLight[id].rgb.g = 0.4f; DynLight[id].rgb.b = 1.0f; DynLight[id].pos.x = eSrc.x; DynLight[id].pos.y = eSrc.y - 50.f; DynLight[id].pos.z = eSrc.z; DynLight[id].duration = 200; DynLight[id].extras = 0; } unsigned long ulCalc = ulDuration - ulCurrentTime ; ARX_CHECK_LONG(ulCalc); long ff = ARX_CLEAN_WARN_CAST_LONG(ulCalc); if (ff < 1500) { pPS->uMaxParticles = 0; pPS->ulParticleSpawn = PARTICLE_CIRCULAR; pPS->p3ParticleGravity.x = 0; pPS->p3ParticleGravity.y = 0; pPS->p3ParticleGravity.z = 0; list<CParticle *>::iterator i; for (i = pPS->listParticle.begin(); i != pPS->listParticle.end(); ++i) { CParticle * pP = *i; if (pP->isAlive()) { pP->fColorEnd[3] = 0; if (pP->ulTime + ff < pP->ulTTL) { pP->ulTime = pP->ulTTL - ff; } } } } pPS->SetPos(eSrc); pPS->Update(aulTime); }
void TreatBackgroundDynlights() { ARX_PROFILE_FUNC(); for(size_t i = 0; i < MAX_LIGHTS; i++) { EERIE_LIGHT *light = GLight[i]; if(light && (light->extras & EXTRAS_SEMIDYNAMIC)) { float fMaxdist = player.m_telekinesis ? 850 : 300; if(!fartherThan(light->pos, ACTIVECAM->orgTrans.pos, fMaxdist)) { ComputeLight2DPos(light); } else { light->m_screenRect.max.x = -1; light->m_screenRect.min.x = 1; } if(!light->m_ignitionStatus) { // just extinguished if(lightHandleIsValid(light->m_ignitionLightHandle)) { lightHandleGet(light->m_ignitionLightHandle)->exist = 0; light->m_ignitionLightHandle = LightHandle(); for(size_t l = 0; l < entities.size(); l++) { const EntityHandle handle = EntityHandle(l); Entity * e = entities[handle]; if(e && (e->ioflags & IO_MARKER)) { Vec3f _pos2 = GetItemWorldPosition(e); if(!fartherThan(light->pos, _pos2, 300.f)) { SendIOScriptEvent(e, SM_CUSTOM, "douse"); } } } } } else { // just light up if(!lightHandleIsValid(light->m_ignitionLightHandle)) { for(size_t l = 0; l < entities.size(); l++) { const EntityHandle handle = EntityHandle(l); Entity * e = entities[handle]; if(e && (e->ioflags & IO_MARKER)) { Vec3f _pos2 = GetItemWorldPosition(e); if(!fartherThan(light->pos, _pos2, 300.f)) { SendIOScriptEvent(e, SM_CUSTOM, "fire"); } } } light->m_ignitionLightHandle = GetFreeDynLight(); } if(lightHandleIsValid(light->m_ignitionLightHandle)) { EERIE_LIGHT *dynamicLight = lightHandleGet(light->m_ignitionLightHandle); dynamicLight->pos = light->pos; dynamicLight->fallstart = light->fallstart; dynamicLight->fallend = light->fallend; dynamicLight->m_isIgnitionLight = true; dynamicLight->intensity = light->intensity; dynamicLight->ex_flaresize = light->ex_flaresize; dynamicLight->extras = light->extras; dynamicLight->duration = std::numeric_limits<long>::max(); dynamicLight->rgb = light->rgb - light->rgb * light->ex_flicker * randomColor3f() * 0.5f; dynamicLight->rgb = componentwise_max(dynamicLight->rgb, Color3f::black); RecalcLight(dynamicLight); } } } } for(size_t i = 0; i < MAX_DYNLIGHTS; i++) { EERIE_LIGHT * el = &DynLight[i]; if(el->exist && el->duration) { float tim = (float)float(arxtime) - (float)el->time_creation; float duration = (float)el->duration; if(tim >= duration) { float sub = framedelay * 0.001f; el->rgb.r -= sub; el->rgb.g -= sub; el->rgb.b -= sub; if(el->rgb.r < 0) el->rgb.r = 0.f; if(el->rgb.g < 0) el->rgb.g = 0.f; if(el->rgb.b < 0) el->rgb.b = 0.f; if(el->rgb.r + el->rgb.g + el->rgb.b == 0) { el->exist = 0; el->duration = 0; } } } } }
//TODO Move somewhere else void Cedric_ApplyLightingFirstPartRefactor(Entity *io) { if(!io) return; io->special_color = Color3f::white; float poisonpercent = 0.f; float trappercent = 0.f; float secretpercent = 0.f; if((io->ioflags & IO_NPC) && io->_npcdata->poisonned > 0.f) { poisonpercent = io->_npcdata->poisonned * ( 1.0f / 20 ); if(poisonpercent > 1.f) poisonpercent = 1.f; } if((io->ioflags & IO_ITEM) && io->poisonous > 0.f && io->poisonous_count) { poisonpercent = (float)io->poisonous * (1.0f / 20); if(poisonpercent > 1.f) poisonpercent = 1.f; } if((io->ioflags & IO_FIX) && io->_fixdata->trapvalue > -1) { trappercent = player.TRAP_DETECT - (float)io->_fixdata->trapvalue; if(trappercent > 0.f) { trappercent = 0.6f + trappercent * ( 1.0f / 100 ); trappercent = clamp(trappercent, 0.6f, 1.f); } } if((io->ioflags & IO_FIX) && io->secretvalue > -1) { secretpercent = player.TRAP_SECRET - (float)io->secretvalue; if(secretpercent > 0.f) { secretpercent = 0.6f + secretpercent * ( 1.0f / 100 ); secretpercent = clamp(secretpercent, 0.6f, 1.f); } } if(poisonpercent > 0.f) { io->special_color = Color3f::green; } if(trappercent > 0.f) { io->special_color = Color3f(trappercent, 1.f - trappercent, 1.f - trappercent); } if(secretpercent > 0.f) { io->special_color = Color3f(1.f - secretpercent, 1.f - secretpercent, secretpercent); } if(io->ioflags & IO_FREEZESCRIPT) { io->special_color = Color3f::blue; } if(io->sfx_flag & SFX_TYPE_YLSIDE_DEATH) { if(io->show == SHOW_FLAG_TELEPORTING) { float fTime = io->sfx_time + framedelay; io->sfx_time = checked_range_cast<unsigned long>(fTime); if (io->sfx_time >= (unsigned long)(arxtime)) io->sfx_time = (unsigned long)(arxtime); } else { float elapsed = float(arxtime) - io->sfx_time; if(elapsed > 0.f) { if(elapsed < 3000.f) { // 5 seconds to red float ratio = elapsed * (1.0f / 3000); io->special_color = Color3f(1.f, 1.f - ratio, 1.f - ratio); AddRandomSmoke(io, 1); } else if(elapsed < 6000.f) { // 5 seconds to White float ratio = (elapsed - 3000.f) * (1.0f / 3000); io->special_color = Color3f(1.f, ratio, ratio); AddRandomSmoke(io, 2); } else { // SFX finish io->sfx_time = 0; if(io->ioflags & IO_NPC) { MakePlayerAppearsFX(io); AddRandomSmoke(io, 50); Color3f rgb = io->_npcdata->blood_color.to<float>(); EERIE_SPHERE sp; sp.origin = io->pos; sp.radius = 200.f; long count = 6; while(count--) { SpawnGroundSplat(&sp, &rgb, rnd() * 30.f + 30.f, 1); sp.origin.y -= rnd() * 150.f; ARX_PARTICLES_Spawn_Splat(sp.origin, 200.f, io->_npcdata->blood_color); sp.origin.x = io->pos.x + rnd() * 200.f - 100.f; sp.origin.y = io->pos.y + rnd() * 20.f - 10.f; sp.origin.z = io->pos.z + rnd() * 200.f - 100.f; sp.radius = rnd() * 100.f + 100.f; } long nn = GetFreeDynLight(); if(nn >= 0) { DynLight[nn].exist = 1; DynLight[nn].intensity = 0.7f + 2.f * rnd(); DynLight[nn].fallend = 600.f; DynLight[nn].fallstart = 400.f; DynLight[nn].rgb.r = 1.0f; DynLight[nn].rgb.g = 0.8f; DynLight[nn].rgb.b = .0f; DynLight[nn].pos.x = io->pos.x; DynLight[nn].pos.y = io->pos.y - 80.f; DynLight[nn].pos.z = io->pos.z; DynLight[nn].duration = 600; } if(io->sfx_flag & SFX_TYPE_INCINERATE) { io->sfx_flag &= ~SFX_TYPE_INCINERATE; io->sfx_flag &= ~SFX_TYPE_YLSIDE_DEATH; long num = ARX_SPELLS_GetSpellOn(io, SPELL_INCINERATE); if(num < 0) num = ARX_SPELLS_GetSpellOn(io, SPELL_MASS_INCINERATE); if(num >= 0) { spells[num].tolive = 0; float damages = 20 * spells[num].caster_level; damages = ARX_SPELLS_ApplyFireProtection(io, damages); if (ValidIONum(spells[num].caster)) ARX_DAMAGES_DamageNPC(io, damages, spells[num].caster, 1, &entities[spells[num].caster]->pos); else ARX_DAMAGES_DamageNPC(io, damages, spells[num].caster, 1, &io->pos); ARX_SOUND_PlaySFX(SND_SPELL_FIRE_HIT, &io->pos); } } else { io->sfx_flag &= ~SFX_TYPE_YLSIDE_DEATH; ARX_INTERACTIVE_DestroyIOdelayed(io); } } } } } } }
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; } }