//************************************************************************************* //************************************************************************************* BOOL EERIE_LINKEDOBJ_LinkObjectToObject(EERIE_3DOBJ * obj, EERIE_3DOBJ * tolink, char * actiontext, char * actiontext2, INTERACTIVE_OBJ * io) { long group = -1; long ni = GetActionPointIdx(obj, actiontext); if (ni < 0) { return FALSE; } long n = EERIE_LINKEDOBJ_Create(obj); if (n == -1) return FALSE; group = GetActionPointGroup(obj, ni); if (group < 0) return FALSE; long ni2 = GetActionPointIdx(tolink, actiontext2); if (ni2 < 0) return FALSE; obj->linked[n].lidx2 = ni2; obj->linked[n].lidx = ni; obj->linked[n].lgroup = group; obj->linked[n].obj = tolink; obj->linked[n].io = io; return TRUE; }
void EERIE_Object_Precompute_Fast_Access(EERIE_3DOBJ * eerie) { if(!eerie) return; // GetActionPointIdx(eerie, "v_right"); // GetActionPointIdx(eerie, "u_right"); // GetActionPointIdx(eerie, "carry_attach"); // EERIE_OBJECT_GetGroup(eerie, "jaw"); // EERIE_OBJECT_GetGroup(eerie, "mouth all"); eerie->fastaccess.view_attach = GetActionPointIdx(eerie, "view_attach"); eerie->fastaccess.primary_attach = GetActionPointIdx(eerie, "primary_attach"); eerie->fastaccess.left_attach = GetActionPointIdx(eerie, "left_attach"); eerie->fastaccess.weapon_attach = GetActionPointIdx(eerie, "weapon_attach"); eerie->fastaccess.secondary_attach = GetActionPointIdx(eerie, "secondary_attach"); eerie->fastaccess.fire = GetActionPointIdx(eerie, "fire"); eerie->fastaccess.head_group = EERIE_OBJECT_GetGroup(eerie, "head"); if(eerie->fastaccess.head_group == -1) eerie->fastaccess.head_group_origin = -1; else { long lHeadOrigin = eerie->grouplist[eerie->fastaccess.head_group].origin; eerie->fastaccess.head_group_origin = checked_range_cast<short>(lHeadOrigin); } eerie->fastaccess.sel_head = EERIE_OBJECT_GetSelection(eerie, "head"); eerie->fastaccess.sel_chest = EERIE_OBJECT_GetSelection(eerie, "chest"); eerie->fastaccess.sel_leggings = EERIE_OBJECT_GetSelection(eerie, "leggings"); }
void EERIE_Object_Precompute_Fast_Access(EERIE_3DOBJ * eerie) { if(!eerie) return; // GetActionPointIdx(eerie, "v_right"); // GetActionPointIdx(eerie, "u_right"); // GetActionPointIdx(eerie, "carry_attach"); // EERIE_OBJECT_GetGroup(eerie, "jaw"); // EERIE_OBJECT_GetGroup(eerie, "mouth all"); eerie->fastaccess.view_attach = GetActionPointIdx(eerie, "view_attach"); eerie->fastaccess.primary_attach = GetActionPointIdx(eerie, "primary_attach"); eerie->fastaccess.left_attach = GetActionPointIdx(eerie, "left_attach"); eerie->fastaccess.weapon_attach = GetActionPointIdx(eerie, "weapon_attach"); eerie->fastaccess.secondary_attach = GetActionPointIdx(eerie, "secondary_attach"); eerie->fastaccess.fire = GetActionPointIdx(eerie, "fire"); eerie->fastaccess.head_group = EERIE_OBJECT_GetGroup(eerie, "head"); if(eerie->fastaccess.head_group != ObjVertGroup()) { ObjVertHandle lHeadOrigin = ObjVertHandle(eerie->grouplist[eerie->fastaccess.head_group.handleData()].origin); eerie->fastaccess.head_group_origin = lHeadOrigin; } eerie->fastaccess.sel_head = EERIE_OBJECT_GetSelection(eerie, "head"); eerie->fastaccess.sel_chest = EERIE_OBJECT_GetSelection(eerie, "chest"); eerie->fastaccess.sel_leggings = EERIE_OBJECT_GetSelection(eerie, "leggings"); }
void FlyingEyeSpell::Update(float timeDelta) { ARX_UNUSED(timeDelta); const unsigned long tim = (unsigned long)(arxtime); const long framediff3 = tim - m_lastupdate; eyeball.floating = std::sin(m_lastupdate-m_timcreation * 0.001f); eyeball.floating *= 10.f; if(m_lastupdate-m_timcreation <= 3000) { eyeball.exist = m_lastupdate - m_timcreation * (1.0f / 30); eyeball.size = Vec3f(1.f - float(eyeball.exist) * 0.01f); eyeball.angle.setPitch(eyeball.angle.getPitch() + framediff3 * 0.6f); } else { eyeball.exist = 2; } m_lastupdate=tim; Entity * io = entities.player(); EERIE_3DOBJ * eobj = io->obj; long pouet = 2; while(pouet) { long id; if(pouet == 2) id = io->obj->fastaccess.primary_attach; else id = GetActionPointIdx(io->obj, "left_attach"); pouet--; if(id != -1) { if(!lightHandleIsValid(special[pouet])) { special[pouet] = GetFreeDynLight(); } if(lightHandleIsValid(special[pouet])) { EERIE_LIGHT * el = lightHandleGet(special[pouet]); el->intensity = 1.3f; el->fallend = 180.f; el->fallstart = 50.f; el->rgb = Color3f(0.7f, 0.3f, 1.f); el->pos = eobj->vertexlist3[id].v; } for(long kk = 0; kk < 2; kk++) { PARTICLE_DEF * pd = createParticle(); if(!pd) { break; } pd->ov = eobj->vertexlist3[id].v + randomVec(-1.f, 1.f); pd->move = Vec3f(0.1f, 0.f, 0.1f) + Vec3f(-0.2f, -2.2f, -0.2f) * Vec3f(rnd(), rnd(), rnd()); pd->siz = 5.f; pd->tolive = Random::get(1500, 3500); pd->scale = Vec3f(0.2f); pd->tc = TC_smoke; pd->special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING; pd->sourceionum = PlayerEntityHandle; pd->source = &eobj->vertexlist3[id].v; pd->fparam = 0.0000001f; pd->rgb = Color3f(.7f, .3f, 1.f) + Color3f(-.1f, -.1f, -.1f) * Color3f(rnd(), rnd(), rnd()); } } } }
//----------------------------------------------------------------------------- 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::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); }
void MagicMissileSpell::Launch() { m_duration = 20000; // TODO probably never read long number; if(sp_max || cur_rf == 3) { number = long(m_level); } else { number = glm::clamp(long(m_level + 1) / 2, 1l, 5l); } bool mrCheat = (m_caster == PlayerEntityHandle && cur_mr == 3); CMultiMagicMissile * effect = new CMultiMagicMissile(number, mrCheat); effect->SetDuration(6000ul); { m_hand_group = GetActionPointIdx(entities[m_caster]->obj, "primary_attach"); if(m_hand_group != -1) { Entity * caster = entities[m_caster]; long group = m_hand_group; m_hand_pos = caster->obj->vertexlist3[group].v; } Vec3f aePos; float afAlpha, afBeta; if(m_caster == PlayerEntityHandle) { afBeta = player.angle.getPitch(); afAlpha = player.angle.getYaw(); Vec3f vector; vector.x = -std::sin(glm::radians(afBeta)) * std::cos(glm::radians(afAlpha)) * 60.f; vector.y = std::sin(glm::radians(afAlpha)) * 60.f; vector.z = std::cos(glm::radians(afBeta)) * std::cos(glm::radians(afAlpha)) * 60.f; if(m_hand_group != -1) { aePos = m_hand_pos + vector; } else { aePos.x = player.pos.x - std::sin(glm::radians(afBeta)) + vector.x; aePos.y = player.pos.y + vector.y; //; aePos.z = player.pos.z + std::cos(glm::radians(afBeta)) + vector.z; } } else { afAlpha = 0; afBeta = entities[m_caster]->angle.getPitch(); Vec3f vector; vector.x = -std::sin(glm::radians(afBeta)) * std::cos(glm::radians(afAlpha)) * 60; vector.y = std::sin(glm::radians(afAlpha)) * 60; vector.z = std::cos(glm::radians(afBeta)) * std::cos(glm::radians(afAlpha)) * 60; if(m_hand_group != -1) { aePos = m_hand_pos + vector; } else { aePos = entities[m_caster]->pos + vector; } Entity * io = entities[m_caster]; if(ValidIONum(io->targetinfo)) { Vec3f * p1 = &m_caster_pos; Vec3f * p2 = &entities[io->targetinfo]->pos; afAlpha = -(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)) { Vec3f * p1 = &m_caster_pos; Vec3f * p2 = &entities[m_target]->pos; afAlpha = -(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; } } effect->Create(aePos, afAlpha, afBeta); } m_pSpellFx = effect; m_duration = effect->GetDuration(); }