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 CMultiMagicMissile::CheckCollision() { if(!pTab) return; for(unsigned int i = 0; i < uiNumber; i++) { if(pTab[i]) { CMagicMissile * pMM = (CMagicMissile *) pTab[i]; if(!pMM->bExplo) { EERIE_SPHERE sphere; sphere.origin = pMM->eCurPos; sphere.radius = 10.f; if(spellinstance != -1 && (CheckAnythingInSphere(&sphere, spells[spellinstance].caster, CAS_NO_SAME_GROUP))) { LaunchMagicMissileExplosion(pMM->eCurPos, 0, spellinstance); ARX_NPC_SpawnAudibleSound(&pMM->eCurPos, entities[spells[spellinstance].caster]); pMM->SetTTL(1000); pMM->bExplo = true; pMM->bMove = false; if(pMM->lLightId != -1) pMM->lLightId = -1; long ttt = ARX_DAMAGES_GetFree(); if(ttt != -1) { damages[ttt].pos = pMM->eCurPos; damages[ttt].radius = 80.f; damages[ttt].damages = (4 + spells[spellinstance].caster_level * ( 1.0f / 5 )) * .8f; damages[ttt].area = DAMAGE_FULL; damages[ttt].duration = -1; damages[ttt].source = spells[spellinstance].caster; damages[ttt].flags = DAMAGE_FLAG_DONT_HURT_SOURCE; damages[ttt].type = DAMAGE_TYPE_MAGICAL; damages[ttt].exist = true; } Color3f rgb(.3f, .3f, .45f); ARX_PARTICLES_Add_Smoke(&pMM->eCurPos, 0, 6, &rgb); } } } } }
void CMultiMagicMissile::CheckCollision(float level, EntityHandle caster) { for(size_t i = 0; i < pTab.size(); i++) { CMagicMissile * missile = (CMagicMissile *) pTab[i]; if(missile->bExplo) continue; Sphere sphere; sphere.origin = missile->eCurPos; sphere.radius = 10.f; if(CheckAnythingInSphere(sphere, caster, CAS_NO_SAME_GROUP)) { LaunchMagicMissileExplosion(missile->eCurPos, m_mrCheat); ARX_NPC_SpawnAudibleSound(missile->eCurPos, entities[caster]); missile->SetTTL(1000); missile->bExplo = true; missile->bMove = false; missile->lLightId = LightHandle::Invalid; DamageParameters damage; damage.pos = missile->eCurPos; damage.radius = 80.f; damage.damages = (4 + level * ( 1.0f / 5 )) * .8f; damage.area = DAMAGE_FULL; damage.duration = -1; damage.source = caster; damage.flags = DAMAGE_FLAG_DONT_HURT_SOURCE; damage.type = DAMAGE_TYPE_MAGICAL; DamageCreate(damage); Color3f rgb(.3f, .3f, .45f); ARX_PARTICLES_Add_Smoke(&missile->eCurPos, 0, 6, &rgb); } } }
//----------------------------------------------------------------------------- void CMultiMagicMissile::CheckCollision(float _fPlayer_Magic_Level) { if (pTab) { for (UINT i = 0 ; i < uiNumber ; i++) { if (pTab[i]) { CMagicMissile * pMM = (CMagicMissile *) pTab[i]; if (pMM->bExplo == false) { EERIE_SPHERE sphere; sphere.origin.x = pMM->eCurPos.x; sphere.origin.y = pMM->eCurPos.y; sphere.origin.z = pMM->eCurPos.z; sphere.radius = 10.f; if ((spellinstance != -1) && (CheckAnythingInSphere(&sphere, spells[spellinstance].caster, CAS_NO_SAME_GROUP))) { EERIE_3D eE3D; eE3D.x = pMM->eCurPos.x; eE3D.y = pMM->eCurPos.y; eE3D.z = pMM->eCurPos.z; LaunchMagicMissileExplosion(pMM->eCurPos, 0, spellinstance); ARX_NPC_SpawnAudibleSound(&pMM->eCurPos, inter.iobj[spells[spellinstance].caster]); pMM->SetTTL(1000); pMM->bExplo = true; pMM->bMove = false; if (pMM->lLightId != -1) { pMM->lLightId = -1; } long ttt = ARX_DAMAGES_GetFree(); if (ttt != -1) { damages[ttt].pos.x = pMM->eCurPos.x; damages[ttt].pos.y = pMM->eCurPos.y; damages[ttt].pos.z = pMM->eCurPos.z; damages[ttt].radius = 80.f; damages[ttt].damages = (4 + spells[spellinstance].caster_level * DIV5) * .8f; damages[ttt].area = DAMAGE_FULL; damages[ttt].duration = -1; damages[ttt].source = spells[spellinstance].caster; damages[ttt].flags = DAMAGE_FLAG_DONT_HURT_SOURCE; damages[ttt].type = DAMAGE_TYPE_MAGICAL; damages[ttt].exist = TRUE; } EERIE_RGB rgb; rgb.r = 0.3f; rgb.g = 0.3f; rgb.b = 0.45f; ARX_PARTICLES_Add_Smoke(&pMM->eCurPos, 0, 6, &rgb); } } } } } }
//----------------------------------------------------------------------------- void CMultiMagicMissile::Create(EERIE_3D aePos, EERIE_3D angles) { long lMax = 0; if (pTab) { float afAlpha = angles.a; float afBeta = angles.b; spells[spellinstance].hand_group = GetActionPointIdx(inter.iobj[spells[spellinstance].caster]->obj, "PRIMARY_ATTACH"); if (spells[spellinstance].hand_group != -1) { spells[spellinstance].hand_pos.x = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.x; spells[spellinstance].hand_pos.y = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.y; spells[spellinstance].hand_pos.z = inter.iobj[spells[spellinstance].caster]->obj->vertexlist3[spells[spellinstance].hand_group].v.z; } if (spells[spellinstance].caster == 0) // player { afBeta = player.angle.b; afAlpha = player.angle.a; EERIE_3D vector; vector.x = -EEsin(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60.f; vector.y = EEsin(DEG2RAD(afAlpha)) * 60.f; vector.z = EEcos(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60.f; if (spells[spellinstance].hand_group != -1) { aePos.x = spells[spellinstance].hand_pos.x + vector.x; aePos.y = spells[spellinstance].hand_pos.y + vector.y; aePos.z = spells[spellinstance].hand_pos.z + vector.z; } else { aePos.x = player.pos.x - EEsin(DEG2RAD(afBeta)) + vector.x; aePos.y = player.pos.y + vector.y; //; aePos.z = player.pos.z + EEcos(DEG2RAD(afBeta)) + vector.z; } } else { afAlpha = 0; afBeta = inter.iobj[spells[spellinstance].caster]->angle.b; EERIE_3D vector; vector.x = -EEsin(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60; vector.y = EEsin(DEG2RAD(afAlpha)) * 60; vector.z = EEcos(DEG2RAD(afBeta)) * EEcos(DEG2RAD(afAlpha)) * 60; if (spells[spellinstance].hand_group != -1) { aePos.x = spells[spellinstance].hand_pos.x + vector.x; aePos.y = spells[spellinstance].hand_pos.y + vector.y; aePos.z = spells[spellinstance].hand_pos.z + vector.z; } else { aePos.x = inter.iobj[spells[spellinstance].caster]->pos.x + vector.x; aePos.y = inter.iobj[spells[spellinstance].caster]->pos.y + vector.y; aePos.z = inter.iobj[spells[spellinstance].caster]->pos.z + vector.z; } INTERACTIVE_OBJ * io = inter.iobj[spells[spellinstance].caster]; if (ValidIONum(io->targetinfo)) { EERIE_3D * p1 = &spells[spellinstance].caster_pos; EERIE_3D * p2 = &inter.iobj[io->targetinfo]->pos; afAlpha = -(RAD2DEG(GetAngle(p1->y, p1->z, p2->y, p2->z + TRUEDistance2D(p2->x, p2->z, p1->x, p1->z)))); //alpha entre orgn et dest; } else if (ValidIONum(spells[spellinstance].target)) { EERIE_3D * p1 = &spells[spellinstance].caster_pos; EERIE_3D * p2 = &inter.iobj[spells[spellinstance].target]->pos; afAlpha = -(RAD2DEG(GetAngle(p1->y, p1->z, p2->y, p2->z + TRUEDistance2D(p2->x, p2->z, p1->x, p1->z)))); //alpha entre orgn et dest; } } for (UINT i = 0 ; i < uiNumber ; i++) { if (pTab[i]) { EERIE_3D angles; angles.a = afAlpha; angles.b = afBeta; angles.g = 0; if (i > 0) { angles.a += frand2() * 4.0f; angles.b += frand2() * 6.0f; } pTab[i]->Create(aePos, angles); float fTime = ulDuration + frand2() * 1000.0f; ARX_CHECK_LONG(fTime); long lTime = ARX_CLEAN_WARN_CAST_LONG(fTime); lTime = max(1000, lTime); lMax = max(lMax, lTime); CMagicMissile * pMM = (CMagicMissile *)pTab[i]; pMM->SetDuration(lTime); if ((spells[spellinstance].caster == 0) && (cur_mr == 3)) { pMM->SetColor(0.9f, 0.2f, 0.5f); pMM->SetColor1(0.9f, 0.2f, 0.5f); } else { pMM->SetColor(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f); pMM->SetColor1(0.9f + rnd() * 0.1f, 0.9f + rnd() * 0.1f, 0.7f + rnd() * 0.3f); } pTab[i]->lLightId = GetFreeDynLight(); if (pTab[i]->lLightId != -1) { EERIE_LIGHT * el = &DynLight[pTab[i]->lLightId]; el->exist = 1; el->intensity = 0.7f + 2.3f; el->fallend = 190.f; el->fallstart = 80.f; if ((spells[spellinstance].caster == 0) && (cur_mr == 3)) { 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.x = pMM->eSrc.x; el->pos.y = pMM->eSrc.y; el->pos.z = pMM->eSrc.z; el->duration = 300; } } } } SetDuration(lMax + 1000); }
void MagicMissileSpell::Update() { for(size_t i = 0; i < pTab.size(); i++) { CMagicMissile * missile = pTab[i]; if(missile->bExplo) continue; Sphere sphere = Sphere(missile->eCurPos, 10.f); if(CheckAnythingInSphere(sphere, m_caster, CAS_NO_SAME_GROUP)) { LaunchMagicMissileExplosion(missile->eCurPos, m_mrCheat); ARX_NPC_SpawnAudibleSound(missile->eCurPos, entities[m_caster]); missile->SetTTL(ArxDurationMs(1000)); missile->bExplo = true; missile->bMove = false; missile->lLightId = LightHandle(); DamageParameters damage; damage.pos = missile->eCurPos; damage.radius = 80.f; damage.damages = (4 + m_level * ( 1.0f / 5 )) * .8f; damage.area = DAMAGE_FULL; damage.duration = ArxDuration(-1); damage.source = m_caster; damage.flags = DAMAGE_FLAG_DONT_HURT_SOURCE; damage.type = DAMAGE_TYPE_MAGICAL; DamageCreate(damage); Color3f rgb(.3f, .3f, .45f); ARX_PARTICLES_Add_Smoke(missile->eCurPos, 0, 6, rgb); } } for(size_t i = 0 ; i < pTab.size() ; i++) { pTab[i]->Update(ArxDurationMs(g_framedelay)); } { // CheckAllDestroyed long nbmissiles = 0; for(size_t i = 0; i < pTab.size(); i++) { CMagicMissile *pMM = pTab[i]; if(pMM->bMove) nbmissiles++; } if(nbmissiles == 0) m_duration = ArxDuration_ZERO; } for(size_t i = 0; i < pTab.size(); i++) { pTab[i]->Render(); CMagicMissile * pMM = pTab[i]; EERIE_LIGHT * el = lightHandleGet(pMM->lLightId); if(el) { el->intensity = 0.7f + 2.3f * pMM->lightIntensityFactor; el->pos = pMM->eCurPos; el->creationTime = arxtime.now(); } } }
void MagicMissileSpell::Launch() { m_duration = ArxDurationMs(6000); m_hand_group = GetActionPointIdx(entities[m_caster]->obj, "primary_attach"); if(m_hand_group != ActionPoint()) { Entity * caster = entities[m_caster]; ActionPoint group = m_hand_group; m_hand_pos = actionPointPosition(caster->obj, group); } Vec3f startPos; float pitch, yaw; if(m_caster == EntityHandle_Player) { yaw = player.angle.getYaw(); pitch = player.angle.getPitch(); Vec3f vector = angleToVector(Anglef(pitch, yaw, 0.f)) * 60.f; if(m_hand_group != ActionPoint()) { startPos = m_hand_pos; } else { startPos = player.pos; startPos += angleToVectorXZ(yaw); } startPos += vector; } else { pitch = 0; yaw = entities[m_caster]->angle.getYaw(); Vec3f vector = angleToVector(Anglef(pitch, yaw, 0.f)) * 60.f; if(m_hand_group != ActionPoint()) { startPos = m_hand_pos; } else { startPos = entities[m_caster]->pos; } startPos += vector; Entity * io = entities[m_caster]; if(ValidIONum(io->targetinfo)) { const Vec3f & p1 = m_caster_pos; const Vec3f & p2 = entities[io->targetinfo]->pos; pitch = -(glm::degrees(getAngle(p1.y, p1.z, p2.y, p2.z + glm::distance(Vec2f(p2.x, p2.z), Vec2f(p1.x, p1.z))))); //alpha entre orgn et dest; } else if (ValidIONum(m_target)) { const Vec3f & p1 = m_caster_pos; const Vec3f & p2 = entities[m_target]->pos; pitch = -(glm::degrees(getAngle(p1.y, p1.z, p2.y, p2.z + glm::distance(Vec2f(p2.x, p2.z), Vec2f(p1.x, p1.z))))); //alpha entre orgn et dest; } } m_mrCheat = (m_caster == EntityHandle_Player && cur_mr == 3); ArxDuration lMax = ArxDuration_ZERO; long number; if(sp_max || cur_rf == 3) { number = long(m_level); } else { number = glm::clamp(long(m_level + 1) / 2, 1l, 5l); } pTab.reserve(number); for(size_t i = 0; i < size_t(number); i++) { CMagicMissile * missile = NULL; if(!m_mrCheat) { missile = new CMagicMissile(); } else { missile = new MrMagicMissileFx(); } pTab.push_back(missile); Anglef angles(pitch, yaw, 0.f); if(i > 0) { angles.setPitch(angles.getPitch() + Random::getf(-4.0f, 4.0f)); angles.setYaw(angles.getYaw() + Random::getf(-6.0f, 6.0f)); } missile->Create(startPos, angles); ArxDuration lTime = m_duration + ArxDurationMs(Random::get(-1000, 1000)); lTime = std::max(ArxDurationMs(1000), lTime); lMax = std::max(lMax, lTime); missile->SetDuration(lTime); EERIE_LIGHT * el = dynLightCreate(missile->lLightId); if(el) { el->intensity = 0.7f + 2.3f; el->fallend = 190.f; el->fallstart = 80.f; if(m_mrCheat) { el->rgb = Color3f(1.f, 0.3f, 0.8f); } else { el->rgb = Color3f(0.f, 0.f, 1.f); } el->pos = startPos; el->duration = ArxDurationMs(300); } } m_duration = lMax + ArxDurationMs(1000); }
void CMultiMagicMissile::Create() { long lMax = 0; if(pTab) { spells[spellinstance].hand_group = GetActionPointIdx(entities[spells[spellinstance].caster]->obj, "primary_attach"); if(spells[spellinstance].hand_group != -1) { Entity * caster = entities[spells[spellinstance].caster]; long group = spells[spellinstance].hand_group; spells[spellinstance].hand_pos = caster->obj->vertexlist3[group].v; } Vec3f aePos; float afAlpha, afBeta; if(spells[spellinstance].caster == 0) { // player afBeta = player.angle.getPitch(); afAlpha = player.angle.getYaw(); Vec3f vector; vector.x = -EEsin(radians(afBeta)) * EEcos(radians(afAlpha)) * 60.f; vector.y = EEsin(radians(afAlpha)) * 60.f; vector.z = EEcos(radians(afBeta)) * EEcos(radians(afAlpha)) * 60.f; if(spells[spellinstance].hand_group != -1) { aePos = spells[spellinstance].hand_pos + vector; } else { aePos.x = player.pos.x - EEsin(radians(afBeta)) + vector.x; aePos.y = player.pos.y + vector.y; //; aePos.z = player.pos.z + EEcos(radians(afBeta)) + vector.z; } } else { afAlpha = 0; afBeta = entities[spells[spellinstance].caster]->angle.getPitch(); Vec3f vector; vector.x = -EEsin(radians(afBeta)) * EEcos(radians(afAlpha)) * 60; vector.y = EEsin(radians(afAlpha)) * 60; vector.z = EEcos(radians(afBeta)) * EEcos(radians(afAlpha)) * 60; if(spells[spellinstance].hand_group != -1) { aePos = spells[spellinstance].hand_pos + vector; } else { aePos = entities[spells[spellinstance].caster]->pos + vector; } Entity * io = entities[spells[spellinstance].caster]; if(ValidIONum(io->targetinfo)) { Vec3f * p1 = &spells[spellinstance].caster_pos; Vec3f * p2 = &entities[io->targetinfo]->pos; afAlpha = -(degrees(getAngle(p1->y, p1->z, p2->y, p2->z + glm::distance(Vec2f(p2->x, p2->z), Vec2f(p1->x, p1->z))))); //alpha entre orgn et dest; } else if (ValidIONum(spells[spellinstance].target)) { Vec3f * p1 = &spells[spellinstance].caster_pos; Vec3f * p2 = &entities[spells[spellinstance].target]->pos; afAlpha = -(degrees(getAngle(p1->y, p1->z, p2->y, p2->z + glm::distance(Vec2f(p2->x, p2->z), Vec2f(p1->x, p1->z))))); //alpha entre orgn et dest; } } for(unsigned int i = 0; i < uiNumber; i++) { if(pTab[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(spells[spellinstance].caster == 0 && cur_mr == 3) { 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(pTab[i]->lLightId != -1) { EERIE_LIGHT * el = &DynLight[pTab[i]->lLightId]; el->exist = 1; el->intensity = 0.7f + 2.3f; el->fallend = 190.f; el->fallstart = 80.f; if(spells[spellinstance].caster == 0 && cur_mr == 3) { 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); }