From 67d5061416a6b253a11506428115e1e7ffac5a2a Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 19 Jan 2022 02:10:04 -0800 Subject: [PATCH 01/24] Implemented Dragon Smash Quick Build for Crux Prime Dragons Implemented a script for the crux prime dragons to spawn the Golem Quick Build that insta kills the Entity if the player hits the dragon after the golem is built. Tested on Local Ubuntu instance against 1 Crux Prime Maelstrom Dragon and 1 Butterscorch and had no issues building the quick build or with the enemy not smashing. Enemies also correctly reset to their default behavior after the stun period has expired. --- dScripts/AmDarklingDragon.cpp | 167 +++++++++++++++++++++++++++++ dScripts/AmDarklingDragon.h | 12 +++ dScripts/AmNamedDarklingDragon.cpp | 12 --- dScripts/AmNamedDarklingDragon.h | 8 -- dScripts/CppScripts.cpp | 7 +- 5 files changed, 182 insertions(+), 24 deletions(-) create mode 100644 dScripts/AmDarklingDragon.cpp create mode 100644 dScripts/AmDarklingDragon.h delete mode 100644 dScripts/AmNamedDarklingDragon.cpp delete mode 100644 dScripts/AmNamedDarklingDragon.h diff --git a/dScripts/AmDarklingDragon.cpp b/dScripts/AmDarklingDragon.cpp new file mode 100644 index 00000000..435fa68d --- /dev/null +++ b/dScripts/AmDarklingDragon.cpp @@ -0,0 +1,167 @@ +#include "AmDarklingDragon.h" +#include "BaseCombatAIComponent.h" +#include "DestroyableComponent.h" +#include "EntityManager.h" +#include "GameMessages.h" +#include "SkillComponent.h" +#include "BaseCombatAIComponent.h" + + +void AmDarklingDragon::OnStartup(Entity* self) { + self->SetVar(u"weakspot", 0); + + auto* baseCombatAIComponent = self->GetComponent(); + + if (baseCombatAIComponent != nullptr) { + baseCombatAIComponent->SetStunImmune(true); + } +} + +void AmDarklingDragon::OnDie(Entity* self, Entity* killer) { + if (self->GetVar(u"bDied")) { + return; + } + + self->SetVar(u"bDied", true); + + auto position = self->GetPosition(); + auto rotation = self->GetRotation(); + + auto golemId = self->GetVar(u"Golem"); + + auto* golem = EntityManager::Instance()->GetEntity(golemId); + + if (golem != nullptr) { + golem->Smash(self->GetObjectID()); + } +} + +void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) { + GameMessages::SendPlayFXEffect(self, -1, u"gothit", "", LWOOBJID_EMPTY, 1, 1, true); + + if (true) { + auto weakpoint = self->GetVar(u"weakspot"); + + if (weakpoint == 1) + { + self->Smash(attacker->GetObjectID()); + } + } + + auto* destroyableComponent = self->GetComponent(); + + if (destroyableComponent != nullptr) { + Game::logger->Log("AmDarklingDragon", "Armor is %i\n", destroyableComponent->GetArmor()); + + if (destroyableComponent->GetArmor() > 0) return; + + auto weakpoint = self->GetVar(u"weakpoint"); + + if (weakpoint == 0) { + Game::logger->Log("AmDarklingDragon", "Activating weakpoint\n"); + + self->AddTimer("ReviveTimer", 12); + + auto* baseCombatAIComponent = self->GetComponent(); + auto* skillComponent = self->GetComponent(); + + if (baseCombatAIComponent != nullptr) { + baseCombatAIComponent->SetDisabled(true); + baseCombatAIComponent->SetStunned(true); + } + + if (skillComponent != nullptr) { + skillComponent->Interrupt(); + } + + self->SetVar(u"weakpoint", 2); + + GameMessages::SendPlayAnimation(self, u"stunstart", 1.7f); + + self->AddTimer("timeToStunLoop", 1); + + auto position = self->GetPosition(); + auto forward = self->GetRotation().GetForwardVector(); + auto backwards = forward * -1; + + forward.x *= 10; + forward.z *= 10; + + auto rotation = self->GetRotation(); + + auto objectPosition = NiPoint3(); + + objectPosition.y = position.y; + objectPosition.x = position.x - (backwards.x * 8); + objectPosition.z = position.z - (backwards.z * 8); + + auto golem = self->GetVar(u"DragonSmashingGolem"); + + EntityInfo info {}; + info.lot = golem != 0 ? golem : 8340; + info.pos = objectPosition; + info.rot = rotation; + info.spawnerID = self->GetObjectID(); + info.settings = { + new LDFData(u"rebuild_activators", + std::to_string(objectPosition.x + forward.x) + "\x1f" + + std::to_string(objectPosition.y) + "\x1f" + + std::to_string(objectPosition.z + forward.z) + ), + new LDFData(u"respawn", 100000), + new LDFData(u"rebuild_reset_time", 15), + new LDFData(u"no_timed_spawn", true), + new LDFData(u"Dragon", self->GetObjectID()) + }; + + auto* golemObject = EntityManager::Instance()->CreateEntity(info); + + EntityManager::Instance()->ConstructEntity(golemObject); + } + } +} + +void AmDarklingDragon::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "ReviveHeldTimer") { + self->AddTimer("backToAttack", 2.5); + } + else if (timerName == "ExposeWeakSpotTimer") { + self->SetVar(u"weakspot", 1); + } + else if (timerName == "timeToStunLoop") { + GameMessages::SendPlayAnimation(self, u"stunloop", 1.8f); + } + else if (timerName == "ReviveTimer") { + GameMessages::SendPlayAnimation(self, u"stunend", 2.0f); + self->AddTimer("backToAttack", 1); + } + else if (timerName == "backToAttack") { + auto* baseCombatAIComponent = self->GetComponent(); + auto* skillComponent = self->GetComponent(); + if (baseCombatAIComponent != nullptr) + { + baseCombatAIComponent->SetDisabled(false); + baseCombatAIComponent->SetStunned(false); + } + if (skillComponent != nullptr) + { + skillComponent->Interrupt(); + } + self->SetVar(u"weakspot", -1); + GameMessages::SendNotifyObject(self->GetObjectID(), self->GetObjectID(), u"DragonRevive", UNASSIGNED_SYSTEM_ADDRESS); + } +} + +void AmDarklingDragon::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + if (args != "rebuildDone") return; + + self->AddTimer("ExposeWeakSpotTimer", 3.8f); + + self->CancelTimer("ReviveTimer"); + + self->AddTimer("ReviveHeldTimer", 10.5f); + + self->SetVar(u"Golem", sender->GetObjectID()); + + GameMessages::SendPlayAnimation(self, u"quickbuildhold", 1.9f); +} \ No newline at end of file diff --git a/dScripts/AmDarklingDragon.h b/dScripts/AmDarklingDragon.h new file mode 100644 index 00000000..8c3617d2 --- /dev/null +++ b/dScripts/AmDarklingDragon.h @@ -0,0 +1,12 @@ +#pragma once +#include "CppScripts.h" + +class AmDarklingDragon : public CppScripts::Script +{ +public: + void OnStartup(Entity* self) override; + void OnDie(Entity* self, Entity* killer) override; + void OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) override; + void OnTimerDone(Entity* self, std::string timerName) override; + void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; +}; diff --git a/dScripts/AmNamedDarklingDragon.cpp b/dScripts/AmNamedDarklingDragon.cpp deleted file mode 100644 index c7f51cbd..00000000 --- a/dScripts/AmNamedDarklingDragon.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "AmNamedDarklingDragon.h" -#include "BaseCombatAIComponent.h" - -void AmNamedDarklingDragon::OnStartup(Entity* self) -{ - auto* baseCombatAIComponent = self->GetComponent(); - - if (baseCombatAIComponent != nullptr) - { - baseCombatAIComponent->SetStunImmune(true); - } -} diff --git a/dScripts/AmNamedDarklingDragon.h b/dScripts/AmNamedDarklingDragon.h deleted file mode 100644 index cad5c2ca..00000000 --- a/dScripts/AmNamedDarklingDragon.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "CppScripts.h" - -class AmNamedDarklingDragon : public CppScripts::Script -{ -public: - void OnStartup(Entity* self) override; -}; diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index f6029076..7cbac5f3 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -219,7 +219,7 @@ #include "AmSkullkinDrill.h" #include "AmSkullkinDrillStand.h" #include "AmSkullkinTower.h" -#include "AmNamedDarklingDragon.h" +#include "AmDarklingDragon.h" #include "AmBlueX.h" // NJ Scripts @@ -675,11 +675,10 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new AmSkullkinDrillStand(); else if (scriptName == "scripts\\02_server\\Map\\AM\\L_SKULLKIN_TOWER.lua") script = new AmSkullkinTower(); - // This just makes them immune to stuns. TODO: Make seperate scripts else if (scriptName == "scripts\\02_server\\Enemy\\AM\\L_AM_NAMED_DARKLING_DRAGON.lua") - script = new AmNamedDarklingDragon(); + script = new AmDarklingDragon(); else if (scriptName == "scripts\\02_server\\Enemy\\AM\\L_AM_DARKLING_DRAGON.lua") - script = new AmNamedDarklingDragon(); + script = new AmDarklingDragon(); else if (scriptName == "scripts\\02_server\\Enemy\\AM\\L_AM_DARKLING_APE.lua") script = new BaseEnemyApe(); else if (scriptName == "scripts\\02_server\\Map\\AM\\L_BLUE_X.lua") From 097af41392cac4608a39cbf162b5ca8b90cbbd6c Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 19 Jan 2022 02:28:50 -0800 Subject: [PATCH 02/24] Deleted unused variables --- dScripts/AmDarklingDragon.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/dScripts/AmDarklingDragon.cpp b/dScripts/AmDarklingDragon.cpp index 435fa68d..be87f466 100644 --- a/dScripts/AmDarklingDragon.cpp +++ b/dScripts/AmDarklingDragon.cpp @@ -23,9 +23,6 @@ void AmDarklingDragon::OnDie(Entity* self, Entity* killer) { } self->SetVar(u"bDied", true); - - auto position = self->GetPosition(); - auto rotation = self->GetRotation(); auto golemId = self->GetVar(u"Golem"); From 46f375a58e37d60227ae13f07e126e1618b261e2 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 19 Jan 2022 02:31:22 -0800 Subject: [PATCH 03/24] Added comments to header file --- dScripts/AmDarklingDragon.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dScripts/AmDarklingDragon.h b/dScripts/AmDarklingDragon.h index 8c3617d2..ea4c2a19 100644 --- a/dScripts/AmDarklingDragon.h +++ b/dScripts/AmDarklingDragon.h @@ -4,9 +4,45 @@ class AmDarklingDragon : public CppScripts::Script { public: + /** + * @brief When called, this function will make self immune to stuns and initialize a weakspot boolean to false. + * + * @param self The Entity that called this function. + */ void OnStartup(Entity* self) override; + /** + * @brief When called, this function will destroy the golem if it was alive, otherwise returns immediately. + * + * @param self The Entity that called this function. + * @param killer The Entity that killed self. + */ void OnDie(Entity* self, Entity* killer) override; + /** + * @brief When self is hit or healed, this function will check if self is at zero armor. If self is at zero armor, a golem Entity Quick Build + * is spawned that, when built, will reveal a weakpoint on the dragon that if hit will smash the dragon instantly. If at more than zero armor, + * this function returns early. + * + * @param self The Entity that was hit. + * @param attacker The Entity that attacked self. + * @param damage The amount of damage attacker did to self. + */ void OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) override; + /** + * @brief Called when self has a timer that ended. + * + * @param self The Entity who owns a timer that finished. + * @param timerName The name of a timer attacked to self that has ended. + */ void OnTimerDone(Entity* self, std::string timerName) override; + /** + * @brief When the Client has finished rebuilding the Golem for the dragon, this function exposes the weak spot for a set amount of time. + * + * @param self The Entity that called this script. + * @param sender The Entity that sent a fired event. + * @param args The argument that tells us what event has been fired off. + * @param param1 Unused in this script. + * @param param2 Unused in this script. + * @param param3 Unused in this script. + */ void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; }; From 72b38127164a926ab9562e7d0fc65ddef358059f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 14:28:15 -0800 Subject: [PATCH 04/24] fixed tab indent --- dGame/dMission/RacingTaskParam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dMission/RacingTaskParam.h b/dGame/dMission/RacingTaskParam.h index e85d9f91..38f8dd8e 100644 --- a/dGame/dMission/RacingTaskParam.h +++ b/dGame/dMission/RacingTaskParam.h @@ -16,5 +16,5 @@ enum class RacingTaskParam : int32_t { RACING_TASK_PARAM_WIN_RACE_IN_WORLD = 14, // Date: Sun, 6 Feb 2022 14:28:27 -0800 Subject: [PATCH 05/24] Added associate for 17 --- dGame/dMission/MissionTask.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dGame/dMission/MissionTask.cpp b/dGame/dMission/MissionTask.cpp index 4c49327d..9bcbdc81 100644 --- a/dGame/dMission/MissionTask.cpp +++ b/dGame/dMission/MissionTask.cpp @@ -420,6 +420,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& case MissionTaskType::MISSION_TASK_TYPE_RACING: { + // The meaning of associate can be found in RacingTaskParam.h if (parameters.empty()) break; if (!InAllTargets(dZoneManager::Instance()->GetZone()->GetWorldID()) && !(parameters[0] == 4 || parameters[0] == 5) && !InAllTargets(value)) break; @@ -444,6 +445,11 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& if (!InAllTargets(value)) break; AddProgress(count); } + else if (associate == 17) + { + if (!InAllTargets(value)) break; + AddProgress(count); + } else { AddProgress(count); From 9cfb9a0de69060216fc1de0bf7a358cd5c744b88 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 14:28:37 -0800 Subject: [PATCH 06/24] Added specific smashable mission progression --- dScripts/FvRaceSmashEggImagineServer.cpp | 4 +++- dScripts/RaceSmashServer.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dScripts/FvRaceSmashEggImagineServer.cpp b/dScripts/FvRaceSmashEggImagineServer.cpp index 68faea04..8e0d0897 100644 --- a/dScripts/FvRaceSmashEggImagineServer.cpp +++ b/dScripts/FvRaceSmashEggImagineServer.cpp @@ -27,7 +27,9 @@ void FvRaceSmashEggImagineServer::OnDie(Entity *self, Entity *killer) { characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed); } if (missionComponent == nullptr) return; - missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASH_DRAGON_EGGS); + // Dragon eggs have their own smash server so we handle mission progression for them here. + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES); + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASH_SPECIFIC_SMASHABLE); } } diff --git a/dScripts/RaceSmashServer.cpp b/dScripts/RaceSmashServer.cpp index 059ac430..582a8ed3 100644 --- a/dScripts/RaceSmashServer.cpp +++ b/dScripts/RaceSmashServer.cpp @@ -22,6 +22,8 @@ void RaceSmashServer::OnDie(Entity *self, Entity *killer) { // Progress racing smashable missions if(missionComponent == nullptr) return; missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES); + // Progress missions that ask us to smash a specific smashable. + missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, self->GetLOT(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASH_SPECIFIC_SMASHABLE); } } } From 3de2c3bfc63a44672c3ba3ea9eb29cd019e4bb40 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 21:32:36 -0800 Subject: [PATCH 07/24] set faction of buff station to 6 --- dScripts/AgSurvivalBuffStation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index 41a754d6..a9a4b75d 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -1,8 +1,13 @@ #include "AgSurvivalBuffStation.h" #include "SkillComponent.h" #include "dLogger.h" +#include "DestroyableComponent.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { + auto destroyableComponent = self->GetComponent(); + + if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); + auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; From f41e8292e82297c07b07dae74466539d97d571bf Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 21:34:26 -0800 Subject: [PATCH 08/24] Clarified numbers and added comments --- dScripts/AgSurvivalBuffStation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index a9a4b75d..17f3335d 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -5,14 +5,14 @@ void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); - + // We set the faction to 6 so that the buff station sees players as friendly targets if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); auto skillComponent = self->GetComponent(); if (skillComponent == nullptr) return; - skillComponent->CalculateBehavior(201, 1784, self->GetObjectID()); + skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); self->AddCallbackTimer(10.0f, [self]() { self->Smash(); From b297d21a8de2b134a6ef14c505ffe4f552eca53f Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 22:15:32 -0800 Subject: [PATCH 09/24] Fully implemented buff station script --- dScripts/AgSurvivalBuffStation.cpp | 38 +++++++++++++++++++++++++----- dScripts/AgSurvivalBuffStation.h | 30 +++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index 17f3335d..d5d2e442 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -1,20 +1,46 @@ #include "AgSurvivalBuffStation.h" +#include "DestroyableComponent.h" +#include "EntityManager.h" +#include "GameMessages.h" #include "SkillComponent.h" #include "dLogger.h" -#include "DestroyableComponent.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); - // We set the faction to 6 so that the buff station sees players as friendly targets + // We set the faction to 6 so that the buff station sees players as friendly targets to buff if (destroyableComponent != nullptr) destroyableComponent->SetFaction(6); auto skillComponent = self->GetComponent(); - if (skillComponent == nullptr) return; + if (skillComponent != nullptr) skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); - skillComponent->CalculateBehavior(skillIdForBuffStation, behaviorIdForBuffStation, self->GetObjectID()); - - self->AddCallbackTimer(10.0f, [self]() { + self->AddCallbackTimer(smashTimer, [self]() { self->Smash(); }); + self->AddTimer("DropArmor", dropArmorTimer); + self->AddTimer("DropLife", dropLifeTimer); + self->AddTimer("Dropimagination", dropImaginationTimer); + self->SetVar(u"PlayerId", target->GetObjectID()); } + +void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { + auto targetID = self->GetVar(u"PlayerId"); + auto target = EntityManager::Instance()->GetEntity(targetID); + uint32_t powerupToDrop = lifePowerup; + if (timerName == "DropArmor") { + powerupToDrop = armorPowerup; + self->AddTimer("DropArmor", dropArmorTimer); + } + if (timerName == "DropLife") { + powerupToDrop = lifePowerup; + self->AddTimer("DropLife", dropLifeTimer); + } + if (timerName == "Dropimagination") { + powerupToDrop = imaginationPowerup; + self->AddTimer("Dropimagination", dropImaginationTimer); + } + if (target != nullptr) GameMessages::SendDropClientLoot(target, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); +} +void AgSurvivalBuffStation::OnDie(Entity* self, Entity* killer) { + //self->CancelAllTimers(); +} \ No newline at end of file diff --git a/dScripts/AgSurvivalBuffStation.h b/dScripts/AgSurvivalBuffStation.h index 0b4d1865..8d756c7d 100644 --- a/dScripts/AgSurvivalBuffStation.h +++ b/dScripts/AgSurvivalBuffStation.h @@ -11,6 +11,8 @@ public: * @param target The target of the self that called this script. */ void OnRebuildComplete(Entity* self, Entity* target) override; + void OnTimerDone(Entity* self, std::string timerName) override; + void OnDie(Entity* self, Entity* killer) override; private: /** * Skill ID for the buff station. @@ -20,4 +22,32 @@ private: * Behavior ID for the buff station. */ uint32_t behaviorIdForBuffStation = 1784; + /** + * Timer for dropping armor. + */ + float dropArmorTimer = 6.0f; + /** + * Timer for dropping life. + */ + float dropLifeTimer = 3.0f; + /** + * Timer for dropping imagination. + */ + float dropImaginationTimer = 4.0f; + /** + * Timer for smashing. + */ + float smashTimer = 25.0f; + /** + * LOT for armor powerup. + */ + LOT armorPowerup = 6431; + /** + * LOT for life powerup. + */ + LOT lifePowerup = 177; + /** + * LOT for imagination powerup. + */ + LOT imaginationPowerup = 935; }; \ No newline at end of file From 204f03fd2a5b51a4a5abf309c9ccc05bca2c5ceb Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 6 Feb 2022 22:19:23 -0800 Subject: [PATCH 10/24] removed extra function --- dScripts/AgSurvivalBuffStation.cpp | 3 --- dScripts/AgSurvivalBuffStation.h | 1 - 2 files changed, 4 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index d5d2e442..c893d684 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -41,6 +41,3 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { } if (target != nullptr) GameMessages::SendDropClientLoot(target, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); } -void AgSurvivalBuffStation::OnDie(Entity* self, Entity* killer) { - //self->CancelAllTimers(); -} \ No newline at end of file diff --git a/dScripts/AgSurvivalBuffStation.h b/dScripts/AgSurvivalBuffStation.h index 8d756c7d..b2beaba6 100644 --- a/dScripts/AgSurvivalBuffStation.h +++ b/dScripts/AgSurvivalBuffStation.h @@ -12,7 +12,6 @@ public: */ void OnRebuildComplete(Entity* self, Entity* target) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnDie(Entity* self, Entity* killer) override; private: /** * Skill ID for the buff station. From a22e1bd53d53f824b53321399055510c91253d80 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:43:09 -0800 Subject: [PATCH 11/24] Added new case in CppScripts --- dScripts/CppScripts.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 53cbf425..4c6e1cde 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -177,6 +177,7 @@ #include "NtVentureCannonServer.h" #include "NtCombatChallengeServer.h" #include "NtCombatChallengeDummy.h" +#include "NtCombatChallengeExplodingDummy.h" #include "BaseInteractDropLootServer.h" #include "NtAssemblyTubeServer.h" #include "NtParadoxPanelServer.h" @@ -603,6 +604,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new NtCombatChallengeServer(); else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_COMBAT_CHALLENGE_DUMMY.lua") script = new NtCombatChallengeDummy(); + else if (scriptName == "scripts\\02_server\\Map\\NT\\\\L_NT_COMBAT_EXPLODING_TARGET.lua") + script = new NtCombatChallengeExplodingDummy(); else if (scriptName == "scripts\\02_server\\Map\\General\\L_BASE_INTERACT_DROP_LOOT_SERVER.lua") script = new BaseInteractDropLootServer(); else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_ASSEMBLYTUBE_SERVER.lua") From 0253a1fcb4472e8544889f0cb285c190c7534e27 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 7 Feb 2022 03:43:30 -0800 Subject: [PATCH 12/24] Added script for exploding asset --- dScripts/NtCombatChallengeExplodingDummy.cpp | 38 ++++++++++++++++++++ dScripts/NtCombatChallengeExplodingDummy.h | 8 +++++ 2 files changed, 46 insertions(+) create mode 100644 dScripts/NtCombatChallengeExplodingDummy.cpp create mode 100644 dScripts/NtCombatChallengeExplodingDummy.h diff --git a/dScripts/NtCombatChallengeExplodingDummy.cpp b/dScripts/NtCombatChallengeExplodingDummy.cpp new file mode 100644 index 00000000..a1b0b288 --- /dev/null +++ b/dScripts/NtCombatChallengeExplodingDummy.cpp @@ -0,0 +1,38 @@ +#include "NtCombatChallengeExplodingDummy.h" +#include "NtCombatChallengeDummy.h" +#include "EntityManager.h" +#include "SkillComponent.h" + +void NtCombatChallengeExplodingDummy::OnDie(Entity* self, Entity* killer) +{ + const auto challengeObjectID = self->GetVar(u"challengeObjectID"); + + auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID); + + if (challengeObject != nullptr) + { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) + { + script->OnDie(challengeObject, killer); + } + } +} + +void NtCombatChallengeExplodingDummy::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) { + const auto challengeObjectID = self->GetVar(u"challengeObjectID"); + + auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID); + + if (challengeObject != nullptr) + { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) + { + script->OnHitOrHealResult(challengeObject, attacker, damage); + } + } + auto skillComponent = self->GetComponent(); + if (skillComponent != nullptr) { + skillComponent->CalculateBehavior(1338, 30875, attacker->GetObjectID()); + } + self->Smash(); +} \ No newline at end of file diff --git a/dScripts/NtCombatChallengeExplodingDummy.h b/dScripts/NtCombatChallengeExplodingDummy.h new file mode 100644 index 00000000..c1c5ef1c --- /dev/null +++ b/dScripts/NtCombatChallengeExplodingDummy.h @@ -0,0 +1,8 @@ +#pragma once +#include "CppScripts.h" + +class NtCombatChallengeExplodingDummy : public CppScripts::Script +{ + void OnDie(Entity* self, Entity* killer) override; + void OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) override; +}; \ No newline at end of file From 1122f50c7c7b74195162a3fd4c93ac211f09b0cb Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:55:25 -0800 Subject: [PATCH 13/24] Changed time when buff station spawns --- dScripts/BaseSurvivalServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/BaseSurvivalServer.cpp b/dScripts/BaseSurvivalServer.cpp index 1174f00b..dd9b9365 100644 --- a/dScripts/BaseSurvivalServer.cpp +++ b/dScripts/BaseSurvivalServer.cpp @@ -200,6 +200,7 @@ void BaseSurvivalServer::OnActivityTimerDone(Entity *self, const std::string &na ActivityTimerStop(self, SpawnTickTimer); ActivityTimerStart(self, CoolDownStopTimer, 1, constants.coolDownTime); + ActivateSpawnerNetwork(spawnerNetworks.rewardNetworks); SpawnerReset(spawnerNetworks.baseNetworks, false); SpawnerReset(spawnerNetworks.randomNetworks, false); } else if (name == CoolDownStopTimer) { @@ -302,7 +303,6 @@ void BaseSurvivalServer::StartWaves(Entity *self) { self->SetVar(FirstTimeDoneVariable, true); self->SetVar(MissionTypeVariable, state.players.size() == 1 ? "survival_time_solo" : "survival_time_team"); - ActivateSpawnerNetwork(spawnerNetworks.rewardNetworks); ActivateSpawnerNetwork(spawnerNetworks.smashNetworks); self->SetNetworkVar(WavesStartedVariable, true); self->SetNetworkVar(StartWaveMessageVariable, "Start!"); From e397ed310ed0bcdab1a5adbf38921b8e8a5bece4 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 8 Feb 2022 02:02:05 -0800 Subject: [PATCH 14/24] Updated script for teams Updated script to drop buffing items for all members in a team. --- dScripts/AgSurvivalBuffStation.cpp | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/dScripts/AgSurvivalBuffStation.cpp b/dScripts/AgSurvivalBuffStation.cpp index c893d684..01fe3976 100644 --- a/dScripts/AgSurvivalBuffStation.cpp +++ b/dScripts/AgSurvivalBuffStation.cpp @@ -4,6 +4,7 @@ #include "GameMessages.h" #include "SkillComponent.h" #include "dLogger.h" +#include "TeamManager.h" void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { auto destroyableComponent = self->GetComponent(); @@ -20,12 +21,24 @@ void AgSurvivalBuffStation::OnRebuildComplete(Entity* self, Entity* target) { self->AddTimer("DropArmor", dropArmorTimer); self->AddTimer("DropLife", dropLifeTimer); self->AddTimer("Dropimagination", dropImaginationTimer); - self->SetVar(u"PlayerId", target->GetObjectID()); + // Since all survival players should be on the same team, we get the team. + auto team = TeamManager::Instance()->GetTeam(target->GetObjectID()); + + std::vector builderTeam; + // Not on a team + if (team == nullptr) { + builderTeam.push_back(target->GetObjectID()); + self->SetVar>(u"BuilderTeam", builderTeam); + return; + } + + for (auto memberID : team->members) { + builderTeam.push_back(memberID); + } + self->SetVar>(u"BuilderTeam", builderTeam); } void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { - auto targetID = self->GetVar(u"PlayerId"); - auto target = EntityManager::Instance()->GetEntity(targetID); uint32_t powerupToDrop = lifePowerup; if (timerName == "DropArmor") { powerupToDrop = armorPowerup; @@ -39,5 +52,15 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { powerupToDrop = imaginationPowerup; self->AddTimer("Dropimagination", dropImaginationTimer); } - if (target != nullptr) GameMessages::SendDropClientLoot(target, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); + auto team = self->GetVar>(u"BuilderTeam"); + for (auto memberID : team) { + auto member = EntityManager::Instance()->GetEntity(memberID); + if (member != nullptr && !member->GetIsDead()) { + GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); + } else { + // If player left the team or left early erase them from the team variable. + team.erase(std::find(team.begin(), team.end(), memberID)); + self->SetVar>(u"BuilderTeam", team); + } + } } From 6be274b25939121ded64f2f8439b2684ac702caa Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:38:25 -0800 Subject: [PATCH 15/24] fixed issue --- dScripts/NtCombatChallengeExplodingDummy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/NtCombatChallengeExplodingDummy.cpp b/dScripts/NtCombatChallengeExplodingDummy.cpp index a1b0b288..dd61817d 100644 --- a/dScripts/NtCombatChallengeExplodingDummy.cpp +++ b/dScripts/NtCombatChallengeExplodingDummy.cpp @@ -34,5 +34,5 @@ void NtCombatChallengeExplodingDummy::OnHitOrHealResult(Entity* self, Entity* at if (skillComponent != nullptr) { skillComponent->CalculateBehavior(1338, 30875, attacker->GetObjectID()); } - self->Smash(); + self->Kill(attacker); } \ No newline at end of file From b2c88bb6a750840d659939396e625079a39b9ed3 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 24 Mar 2022 00:09:18 -0700 Subject: [PATCH 16/24] working query --- dGame/UserManager.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index 1535364c..d1e49cbb 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -6,6 +6,7 @@ #include "Database.h" #include "Game.h" +#include "dLogger.h" #include "User.h" #include #include "Character.h" @@ -572,28 +573,26 @@ uint32_t GetShirtColorId(uint32_t color) { auto colorId = std::find(shirtColorVector.begin(), shirtColorVector.end(), color); return color = std::distance(shirtColorVector.begin(), colorId); } - +// the correct query +/** + * select obj.id, obj.name, obj._internalnotes, icc.color1, icc.decal from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == "character create shirt"; + */ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { - - shirtStyle--; // to start at 0 instead of 1 - uint32_t stylesCount = 34; - uint32_t colorId = GetShirtColorId(shirtColor); - - uint32_t startID = 4049; // item ID of the shirt with color 0 (red) and style 0 (plain) - - // For some reason, if the shirt style is 34 - 39, - // The ID is different than the original... Was this because - // these shirts were added later? - if (shirtStyle >= 34) { - startID = 5730; // item ID of the shirt with color 0 (red) and style 34 (butterflies) - shirtStyle -= stylesCount; //change style from range 35-40 to range 0-5 - stylesCount = 6; + try { + std::string shirtQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"character create shirt\" AND icc.color1 == "; + shirtQuery += std::to_string(shirtColor); + shirtQuery += " AND icc.decal == "; + shirtQuery = shirtQuery + std::to_string(shirtStyle); + auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery); + auto shirtLOT = tableData.getIntField(0, -1); + tableData.finalize(); + return shirtLOT; + } + catch (const std::exception&){ + Game::logger->Log("Character Create", "Failed to use query! Using backup..."); + // in case of no shirt found in CDServer, return problematic red vest. + return 4069; } - - // Get the final ID of the shirt - uint32_t shirtID = startID + (colorId * stylesCount) + shirtStyle; - - return shirtID; } uint32_t FindCharPantsID(uint32_t pantsColor) { From 4e2c352ab92530e016a40edc96dfb515799e2edc Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 24 Mar 2022 00:30:52 -0700 Subject: [PATCH 17/24] Changed pants query and removed extra comments --- dGame/UserManager.cpp | 114 ++++-------------------------------------- dGame/UserManager.h | 40 --------------- 2 files changed, 11 insertions(+), 143 deletions(-) diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index d1e49cbb..f67c0a4f 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -69,16 +69,6 @@ void UserManager::Initialize() { StripCR(line); m_PreapprovedNames.push_back(line); } - - //Load custom ones from MySQL too: - /*sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT name FROM approvedNames;"); - sql::ResultSet* res = stmt->executeQuery(); - while (res->next()) { - m_PreapprovedNames.push_back(res->getString(1)); - } - - delete res; - delete stmt;*/ } UserManager::~UserManager() { @@ -567,16 +557,6 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID } } -uint32_t GetShirtColorId(uint32_t color) { - - // get the index of the color in shirtColorVector - auto colorId = std::find(shirtColorVector.begin(), shirtColorVector.end(), color); - return color = std::distance(shirtColorVector.begin(), colorId); -} -// the correct query -/** - * select obj.id, obj.name, obj._internalnotes, icc.color1, icc.decal from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == "character create shirt"; - */ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { try { std::string shirtQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"character create shirt\" AND icc.color1 == "; @@ -596,91 +576,19 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { } uint32_t FindCharPantsID(uint32_t pantsColor) { - uint32_t pantsID = 2508; - - switch (pantsColor) { - case 0: { - pantsID = PANTS_BRIGHT_RED; - break; + try { + std::string shirtQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"cc pants\" AND icc.color1 == "; + shirtQuery += std::to_string(pantsColor); + auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery); + auto pantsLOT = tableData.getIntField(0, -1); + tableData.finalize(); + return pantsLOT; } - - case 1: { - pantsID = PANTS_BRIGHT_BLUE; - break; + catch (const std::exception&){ + Game::logger->Log("Character Create", "Failed to use query! Using backup..."); + // in case of no pants color found in CDServer, return red pants. + return 2508; } - - case 3: { - pantsID = PANTS_DARK_GREEN; - break; - } - - case 5: { - pantsID = PANTS_BRIGHT_ORANGE; - break; - } - - case 6: { - pantsID = PANTS_BLACK; - break; - } - - case 7: { - pantsID = PANTS_DARK_STONE_GRAY; - break; - } - - case 8: { - pantsID = PANTS_MEDIUM_STONE_GRAY; - break; - } - - case 9: { - pantsID = PANTS_REDDISH_BROWN; - break; - } - - case 10: { - pantsID = PANTS_WHITE; - break; - } - - case 11: { - pantsID = PANTS_MEDIUM_BLUE; - break; - } - - case 13: { - pantsID = PANTS_DARK_RED; - break; - } - - case 14: { - pantsID = PANTS_EARTH_BLUE; - break; - } - - case 15: { - pantsID = PANTS_EARTH_GREEN; - break; - } - - case 16: { - pantsID = PANTS_BRICK_YELLOW; - break; - } - - case 84: { - pantsID = PANTS_SAND_BLUE; - break; - } - - case 96: { - pantsID = PANTS_SAND_GREEN; - break; - } - } - - return pantsID; } void UserManager::SaveAllActiveCharacters() { diff --git a/dGame/UserManager.h b/dGame/UserManager.h index b29cf501..a5db6979 100644 --- a/dGame/UserManager.h +++ b/dGame/UserManager.h @@ -44,7 +44,6 @@ public: private: static UserManager* m_Address; //Singleton - //std::vector m_Users; std::map m_Users; std::vector m_UsersToDelete; @@ -54,43 +53,4 @@ private: std::vector m_PreapprovedNames; }; -enum CharCreatePantsColor : uint32_t { - PANTS_BRIGHT_RED = 2508, - PANTS_BRIGHT_ORANGE = 2509, - PANTS_BRICK_YELLOW = 2511, - PANTS_MEDIUM_BLUE = 2513, - PANTS_SAND_GREEN = 2514, - PANTS_DARK_GREEN = 2515, - PANTS_EARTH_GREEN = 2516, - PANTS_EARTH_BLUE = 2517, - PANTS_BRIGHT_BLUE = 2519, - PANTS_SAND_BLUE = 2520, - PANTS_DARK_STONE_GRAY = 2521, - PANTS_MEDIUM_STONE_GRAY = 2522, - PANTS_WHITE = 2523, - PANTS_BLACK = 2524, - PANTS_REDDISH_BROWN = 2526, - PANTS_DARK_RED = 2527 -}; - -const std::vector shirtColorVector { - 0, // BRIGHT_RED - 1, // BRIGHT_BLUE - 2, // BRIGHT_YELLOW - 3, // DARK_GREEN - 5, // BRIGHT_ORANGE - 6, // BLACK - 7, // DARK_STONE_GRAY - 8, // MEDIUM_STONE_GRAY - 9, // REDDISH_BROWN - 10, // WHITE - 11, // MEDIUM_BLUE - 13, // DARK_RED - 14, // EARTH_BLUE - 15, // EARTH_GREEN - 16, // BRICK_YELLOW - 84, // SAND_BLUE - 96 // SAND_GREEN -}; - #endif // USERMANAGER_H From 819c58df7c17965465087bcbad5087708fce8208 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 24 Mar 2022 00:33:05 -0700 Subject: [PATCH 18/24] semantics --- dGame/UserManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index f67c0a4f..fa34eeaa 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -569,7 +569,7 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { return shirtLOT; } catch (const std::exception&){ - Game::logger->Log("Character Create", "Failed to use query! Using backup..."); + Game::logger->Log("Character Create", "Failed to execute query! Using backup..."); // in case of no shirt found in CDServer, return problematic red vest. return 4069; } @@ -585,7 +585,7 @@ uint32_t FindCharPantsID(uint32_t pantsColor) { return pantsLOT; } catch (const std::exception&){ - Game::logger->Log("Character Create", "Failed to use query! Using backup..."); + Game::logger->Log("Character Create", "Failed to execute query! Using backup..."); // in case of no pants color found in CDServer, return red pants. return 2508; } From f83ad8bbe48ad23c92676a753fb81d71f857e22b Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 23 Mar 2022 18:08:09 -0700 Subject: [PATCH 19/24] fixed wrong stun removal Apes no longer stack their attacks Apes no longer stack their attacks and excess comments removed --- dScripts/BaseEnemyApe.cpp | 20 ++++---------------- dScripts/WaveBossApe.cpp | 1 + 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/dScripts/BaseEnemyApe.cpp b/dScripts/BaseEnemyApe.cpp index 88c846f6..3419b2c4 100644 --- a/dScripts/BaseEnemyApe.cpp +++ b/dScripts/BaseEnemyApe.cpp @@ -8,11 +8,6 @@ void BaseEnemyApe::OnStartup(Entity *self) { self->SetVar(u"timesStunned", 2); self->SetVar(u"knockedOut", false); - - auto* combatAIComponent = self->GetComponent(); - if (combatAIComponent != nullptr) { - combatAIComponent->SetStunImmune(true); - } } void BaseEnemyApe::OnDie(Entity *self, Entity *killer) { @@ -23,10 +18,8 @@ void BaseEnemyApe::OnDie(Entity *self, Entity *killer) { } void BaseEnemyApe::OnSkillCast(Entity *self, uint32_t skillID) { - const auto groundPoundSkill = self->GetVar(u"GroundPoundSkill") != 0 - ? self->GetVar(u"GroundPoundSkill") : 725; - const auto spawnQuickBuildTime = self->GetVar(u"spawnQBTime") != 0.0f - ? self->GetVar(u"spawnQBTime") : 5.0f; + const auto groundPoundSkill = self->GetVar(u"GroundPoundSkill") != 0 ? self->GetVar(u"GroundPoundSkill") : 725; + const auto spawnQuickBuildTime = self->GetVar(u"spawnQBTime") != 0.0f ? self->GetVar(u"spawnQBTime") : 5.0f; if (skillID == groundPoundSkill && self->GetVar(u"QB") == LWOOBJID_EMPTY) { self->AddTimer("spawnQBTime", spawnQuickBuildTime); @@ -61,9 +54,7 @@ void BaseEnemyApe::OnTimerDone(Entity *self, std::string timerName) { StunApe(self, false); } else if (timerName == "spawnQBTime" && self->GetVar(u"QB") == LWOOBJID_EMPTY) { - - // Spawns the QB, which can insta kill the ape - // Quick mafs to spawn the QB in the correct spot + // Spawn QB in front of ape. const auto position = self->GetPosition(); const auto rotation = self->GetRotation(); @@ -107,8 +98,6 @@ void BaseEnemyApe::OnTimerDone(Entity *self, std::string timerName) { auto* skillComponent = self->GetComponent(); if (skillComponent != nullptr) { - // We use a different behavior than the script here, the original one contains a TargetCaster behavior - // but as of writing we can't pass an optional originated to give the loot to the player skillComponent->CalculateBehavior(1273, 29446, self->GetObjectID(), true, false, player->GetObjectID()); } @@ -120,8 +109,7 @@ void BaseEnemyApe::OnFireEventServerSide(Entity *self, Entity *sender, std::stri int32_t param3) { if (args == "rebuildDone" && sender != nullptr) { self->SetVar(u"smasher", sender->GetObjectID()); - const auto anchorDamageDelayTime = self->GetVar(u"AnchorDamageDelayTime") != 0.0f - ? self->GetVar(u"AnchorDamageDelayTime") : 0.5f; + const auto anchorDamageDelayTime = self->GetVar(u"AnchorDamageDelayTime") != 0.0f ? self->GetVar(u"AnchorDamageDelayTime") : 0.5f; self->AddTimer("anchorDamageTimer", anchorDamageDelayTime); } } diff --git a/dScripts/WaveBossApe.cpp b/dScripts/WaveBossApe.cpp index e1860048..c7fdccf2 100644 --- a/dScripts/WaveBossApe.cpp +++ b/dScripts/WaveBossApe.cpp @@ -32,6 +32,7 @@ void WaveBossApe::OnFireEventServerSide(Entity *self, Entity *sender, std::strin auto* combatAIComponent = self->GetComponent(); if (combatAIComponent != nullptr) { combatAIComponent->SetDisabled(false); + combatAIComponent->SetStunImmune(false); } } else { BaseEnemyApe::OnFireEventServerSide(self, sender, args, param1, param2, param3); From db3cd33bca9bdd97cf261fd85d86f2f9ee2e579b Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Thu, 24 Mar 2022 17:51:21 -0700 Subject: [PATCH 20/24] fixed incorrect variable name --- dGame/UserManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index fa34eeaa..61de4ca7 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -577,9 +577,9 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { uint32_t FindCharPantsID(uint32_t pantsColor) { try { - std::string shirtQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"cc pants\" AND icc.color1 == "; - shirtQuery += std::to_string(pantsColor); - auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery); + std::string pantsQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"cc pants\" AND icc.color1 == "; + pantsQuery += std::to_string(pantsColor); + auto tableData = CDClientDatabase::ExecuteQuery(pantsQuery); auto pantsLOT = tableData.getIntField(0, -1); tableData.finalize(); return pantsLOT; From b459790b2ff299f3beae39df84dc0edaad1f06fa Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:24:06 -0700 Subject: [PATCH 21/24] Fixed mission progression --- dGame/dComponents/InventoryComponent.cpp | 26 ++++++++++++------------ dGame/dComponents/InventoryComponent.h | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index c5b4bec3..56bf26d8 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -1043,7 +1043,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) UpdateSlot(item->GetInfo().equipLocation, { item->GetId(), item->GetLot(), item->GetCount(), item->GetSlot() }); - if (item->GetParent() == LWOOBJID_EMPTY) ApplyBuff(item->GetLot()); + ApplyBuff(item); AddItemSkills(item->GetLot()); @@ -1071,7 +1071,7 @@ void InventoryComponent::UnEquipItem(Item* item) set->OnUnEquip(lot); } - if (item->GetParent() == LWOOBJID_EMPTY) RemoveBuff(item->GetLot()); + RemoveBuff(item); RemoveItemSkills(item->GetLot()); @@ -1089,9 +1089,9 @@ void InventoryComponent::UnEquipItem(Item* item) } } -void InventoryComponent::ApplyBuff(const LOT lot) const +void InventoryComponent::ApplyBuff(Item* item) const { - const auto buffs = FindBuffs(lot, true); + const auto buffs = FindBuffs(item, true); for (const auto buff : buffs) { @@ -1099,9 +1099,9 @@ void InventoryComponent::ApplyBuff(const LOT lot) const } } -void InventoryComponent::RemoveBuff(const LOT lot) const +void InventoryComponent::RemoveBuff(Item* item) const { - const auto buffs = FindBuffs(lot, false); + const auto buffs = FindBuffs(item, false); for (const auto buff : buffs) { @@ -1418,18 +1418,18 @@ uint32_t InventoryComponent::FindSkill(const LOT lot) return 0; } -std::vector InventoryComponent::FindBuffs(const LOT lot, bool castOnEquip) const +std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip) const { + std::vector buffs; + if (item == nullptr) return buffs; auto* table = CDClientManager::Instance()->GetTable("ObjectSkills"); auto* behaviors = CDClientManager::Instance()->GetTable("SkillBehavior"); const auto results = table->Query([=](const CDObjectSkills& entry) { - return entry.objectTemplate == static_cast(lot); + return entry.objectTemplate == static_cast(item->GetLot()); }); - std::vector buffs; - auto* missions = static_cast(m_Parent->GetComponent(COMPONENT_TYPE_MISSION)); for (const auto& result : results) @@ -1449,8 +1449,8 @@ std::vector InventoryComponent::FindBuffs(const LOT lot, bool castOnEq { missions->Progress(MissionTaskType::MISSION_TASK_TYPE_SKILL, result.skillID); } - - buffs.push_back(static_cast(entry.behaviorID)); + // If item is not a proxy, add its buff to the added buffs. + if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); } } @@ -1531,7 +1531,7 @@ std::vector InventoryComponent::GenerateProxies(Item* parent) auto* inventory = GetInventory(ITEM_SETS); - auto* proxy = new Item(lot, inventory, inventory->FindEmptySlot(), 1, {}, parent->GetId(), false, parent->GetId()); + auto* proxy = new Item(lot, inventory, inventory->FindEmptySlot(), 1, {}, parent->GetId(), false); EquipItem(proxy); diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 22143802..f754a7fb 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -195,13 +195,13 @@ public: * Adds a buff related to equipping a lot to the entity * @param lot the lot to find buffs for */ - void ApplyBuff(LOT lot) const; + void ApplyBuff(Item* item) const; /** * Removes buffs related to equipping a lot from the entity * @param lot the lot to find buffs for */ - void RemoveBuff(LOT lot) const; + void RemoveBuff(Item* item) const; /** * Saves the equipped items into a temp state @@ -244,7 +244,7 @@ public: * @param castOnEquip if true, the skill missions for these buffs will be progressed * @return the buffs related to the specified lot */ - std::vector FindBuffs(LOT lot, bool castOnEquip) const; + std::vector FindBuffs(Item* item, bool castOnEquip) const; /** * Initializes the equipped items with a list of items From e43517efe66f73bec80f2fd7744d8d245480a53c Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:28:21 -0700 Subject: [PATCH 22/24] comments --- dGame/dComponents/InventoryComponent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index f754a7fb..43fdb084 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -193,13 +193,13 @@ public: /** * Adds a buff related to equipping a lot to the entity - * @param lot the lot to find buffs for + * @param item the item to find buffs for */ void ApplyBuff(Item* item) const; /** * Removes buffs related to equipping a lot from the entity - * @param lot the lot to find buffs for + * @param item the item to find buffs for */ void RemoveBuff(Item* item) const; From a7cd2f4d9bd1cf0420d29b95031562f62487c3f7 Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 27 Mar 2022 15:37:05 -0700 Subject: [PATCH 23/24] comments --- dGame/dComponents/InventoryComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 43fdb084..0a4cfdb3 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -240,7 +240,7 @@ public: /** * Finds all the buffs related to a lot - * @param lot the lot to get the buffs for + * @param item the item to get the buffs for * @param castOnEquip if true, the skill missions for these buffs will be progressed * @return the buffs related to the specified lot */ From 75fd425ef69965cbb4bcfa660ac1aa3493aac3d8 Mon Sep 17 00:00:00 2001 From: Avery Date: Tue, 29 Mar 2022 13:06:28 -0700 Subject: [PATCH 24/24] Remove ability for gmlevel 0 to use /playanim (#391) --- dGame/dUtilities/SlashCommandHandler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 67336eb7..901bccbf 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -363,11 +363,6 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (user->GetMaxGMLevel() == 0 || entity->GetGMLevel() >= 0) { - if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1) { - std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size()); - GameMessages::SendPlayAnimation(entity, anim); - } - if (chatCommand == "die") { entity->Smash(entity->GetObjectID()); } @@ -446,6 +441,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit GameMessages::SendToggleGMInvis(entity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); // need to retoggle because it gets reenabled on creation of new character } + + if ((chatCommand == "playanimation" || chatCommand == "playanim") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { + std::u16string anim = GeneralUtils::ASCIIToUTF16(args[0], args[0].size()); + GameMessages::SendPlayAnimation(entity, anim); + } if (chatCommand == "list-spawns" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) { for (const auto& pair : EntityManager::Instance()->GetSpawnPointEntities()) {