diff --git a/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp b/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp index 703625d2..7fcea9fa 100644 --- a/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp +++ b/dScripts/02_server/Map/AG/AgLaserSensorServer.cpp @@ -2,56 +2,27 @@ #include "PhantomPhysicsComponent.h" #include "SkillComponent.h" -#include "EntityManager.h" -#include "AgMonumentLaserServer.h" -#include "EntityManager.h" #include "ePhysicsEffectType.h" -#include "eReplicaComponentType.h" void AgLaserSensorServer::OnStartup(Entity* self) { - - PhantomPhysicsComponent* physComp = static_cast(self->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS)); - physComp->SetPhysicsEffectActive(true); - physComp->SetEffectType(ePhysicsEffectType::REPULSE); - physComp->SetDirectionalMultiplier(static_cast(m_RepelForce)); - physComp->SetDirection(NiPoint3::UNIT_Y); - - m_Skill = self->GetComponent(); + self->SetBoolean(u"active", true); + auto repelForce = self->GetVarAs(u"repelForce"); + if (!repelForce) repelForce = m_RepelForce; + auto* phantomPhysicsComponent = self->GetComponent(); + if (!phantomPhysicsComponent) return; + phantomPhysicsComponent->SetPhysicsEffectActive(true); + phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE); + phantomPhysicsComponent->SetDirectionalMultiplier(repelForce); + phantomPhysicsComponent->SetDirection(NiPoint3::UNIT_Y); } void AgLaserSensorServer::OnCollisionPhantom(Entity* self, Entity* target) { - - if (!m_Skill) return; - - - Entity* laser = nullptr; - - for (auto script : EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPT)) { - - AgMonumentLaserServer* hasLaser = (AgMonumentLaserServer*)script; - - if (hasLaser) { - const auto source = script->GetPosition(); - const auto obj = self->GetObjectID(); - - if (obj == 76690936093053 && Vector3::DistanceSquared(source, NiPoint3(149.007f, 417.083f, 218.346f)) <= 1.0f) { - laser = script; - break; - } else if (obj == 75866302318824 && Vector3::DistanceSquared(source, NiPoint3(48.6403f, 403.803f, 196.711f)) <= 1.0f) { - laser = script; - break; - } else if (obj == 75866302318822 && Vector3::DistanceSquared(source, NiPoint3(19.2155f, 420.083f, 249.226f)) <= 1.0f) { - laser = script; - break; - } else if (obj == 75866302318823 && Vector3::DistanceSquared(source, NiPoint3(-6.61596f, 404.633f, 274.323f)) <= 1.0f) { - laser = script; - break; - } - } - } - - if (laser != nullptr) { - m_Skill->CalculateBehavior(m_SkillCastID, 15714, target->GetObjectID()); - } + auto active = self->GetVar(u"active"); + if (!active) return; + auto skillCastID = self->GetVarAs(u"skillCastID"); + if (skillCastID == 0) skillCastID = m_SkillCastID; + auto* skillComponent = self->GetComponent(); + if (!skillComponent) return; + skillComponent->CastSkill(m_SkillCastID, target->GetObjectID()); } diff --git a/dScripts/02_server/Map/AG/AgLaserSensorServer.h b/dScripts/02_server/Map/AG/AgLaserSensorServer.h index 72e09dd8..ee7fb6ec 100644 --- a/dScripts/02_server/Map/AG/AgLaserSensorServer.h +++ b/dScripts/02_server/Map/AG/AgLaserSensorServer.h @@ -8,8 +8,7 @@ public: void OnStartup(Entity* self); void OnCollisionPhantom(Entity* self, Entity* target); private: - SkillComponent* m_Skill; - int m_RepelForce = -25; + float m_RepelForce = -25.0f; int m_SkillCastID = 163; }; diff --git a/dScripts/02_server/Map/AG/AgMonumentLaserServer.cpp b/dScripts/02_server/Map/AG/AgMonumentLaserServer.cpp index 6efda89e..b2062935 100644 --- a/dScripts/02_server/Map/AG/AgMonumentLaserServer.cpp +++ b/dScripts/02_server/Map/AG/AgMonumentLaserServer.cpp @@ -1,20 +1,17 @@ #include "AgMonumentLaserServer.h" +#include "EntityManager.h" void AgMonumentLaserServer::OnStartup(Entity* self) { - /* - self->SetProximityRadius(m_Radius, "MonumentLaser"); - - std::cout << "Monument Laser " << self->GetObjectID() << " is at " << self->GetPosition().GetX() - << ","<< self->GetPosition().GetY() << "," << self->GetPosition().GetZ() << std::endl; - */ -} - -void AgMonumentLaserServer::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { - /* - if (status == "ENTER") { - - std::cout << "Monument laser ID: " << self->GetObjectID() << std::endl; + auto lasers = EntityManager::Instance()->GetEntitiesInGroup(self->GetVarAsString(u"volGroup")); + for (auto laser : lasers) { + if (laser) laser->SetBoolean(u"active", true); + } +} + +void AgMonumentLaserServer::OnDie(Entity* self, Entity* killer) { + auto lasers = EntityManager::Instance()->GetEntitiesInGroup(self->GetVarAsString(u"volGroup")); + for (auto laser : lasers) { + if (laser) laser->SetBoolean(u"active", false); } - */ } diff --git a/dScripts/02_server/Map/AG/AgMonumentLaserServer.h b/dScripts/02_server/Map/AG/AgMonumentLaserServer.h index 56979c55..8163948b 100644 --- a/dScripts/02_server/Map/AG/AgMonumentLaserServer.h +++ b/dScripts/02_server/Map/AG/AgMonumentLaserServer.h @@ -3,8 +3,6 @@ class AgMonumentLaserServer : public CppScripts::Script { public: - void OnStartup(Entity* self); - void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status); -private: - float m_Radius = 25.0f; + void OnStartup(Entity* self) override; + void OnDie(Entity* self, Entity* killer) override; };