Merge remote-tracking branch 'upstream/main' into more-cdclient-cleanup

This commit is contained in:
David Markowitz
2023-05-13 16:16:58 -07:00
319 changed files with 4872 additions and 4158 deletions

View File

@@ -9,7 +9,7 @@ void ActMine::OnStartup(Entity* self) {
}
void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
auto* rebuild = self->GetComponent<RebuildComponent>();
if (rebuild) {
auto* builder = rebuild->GetBuilder();

View File

@@ -40,7 +40,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
}
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, true, false, 0);
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0);
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();

View File

@@ -37,7 +37,7 @@ void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, st
if (character != nullptr) {
character->SetPlayerFlag(115, false);
if (param2 != -1) // Certain footraces set a flag
character->SetPlayerFlag(param2, true);
character->SetPlayerFlag(static_cast<uint32_t>(param2), true);
}
StopActivity(self, player->GetObjectID(), 0, param1);

View File

@@ -6,113 +6,55 @@
#include "RenderComponent.h"
void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
if (inUse) {
return;
}
if (inUse || self->GetLOT() != 6859) return;
GameMessages::SendNotifyClientObject(
self->GetObjectID(),
u"isInUse",
0,
0,
LWOOBJID_EMPTY,
"",
UNASSIGNED_SYSTEM_ADDRESS
self->GetObjectID(), u"toggleInUse", 1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
);
inUse = true;
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
if (entities.empty()) {
return;
}
auto* effect = entities[0];
GameMessages::SendPlayFXEffect(effect, 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true);
self->AddTimer("radarDish", 2);
self->AddTimer("CineDone", 9);
if (entities.empty()) return;
GameMessages::SendPlayFXEffect(entities.at(0), 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true);
self->AddTimer("radarDish", 2.0f);
self->AddTimer("PlayEffect", 2.5f);
self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play
}
void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) {
if (self->GetLOT() != 6209) return;
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
if (entities.empty()) return;
RenderComponent::PlayAnimation(entities.at(0), u"jetFX");
if (entities.empty()) {
return;
}
auto* effect = entities[0];
auto groups = self->GetGroups();
if (groups.empty()) {
return;
}
// So we can give kill credit to person who build this
builder = target->GetObjectID();
const auto group = groups[0];
RenderComponent::PlayAnimation(effect, u"jetFX");
self->AddTimer("PlayEffect", 2.5f);
if (group == "Base_Radar") {
self->AddTimer("CineDone", 5);
auto groups = self->GetGroups();
if (!groups.empty() && groups.at(0) == "Base_Radar") {
self->AddTimer("PlayEffect", 2.5f);
self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play
}
}
void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "radarDish") {
GameMessages::SendStopFXEffect(self, true, "radarDish");
return;
}
if (timerName == "PlayEffect") {
} else if (timerName == "PlayEffect") {
auto entities = EntityManager::Instance()->GetEntitiesInGroup("mortarMain");
if (entities.empty()) return;
if (entities.empty()) {
return;
}
const auto size = entities.size();
if (size == 0) {
return;
}
const auto selected = GeneralUtils::GenerateRandomNumber<int>(0, size - 1);
auto* mortar = entities[selected];
Game::logger->Log("AgJetEffectServer", "Mortar (%i) (&d)", mortar->GetLOT(), mortar->HasComponent(eReplicaComponentType::SKILL));
const auto selected = GeneralUtils::GenerateRandomNumber<int>(0, entities.size() - 1);
auto* mortar = entities.at(selected);
// so we give proper credit to the builder for the kills from this skill
mortar->SetOwnerOverride(builder);
SkillComponent* skillComponent;
if (!mortar->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) {
return;
}
skillComponent->CalculateBehavior(318, 3727, LWOOBJID_EMPTY, true);
return;
}
if (timerName == "CineDone") {
auto* skillComponent = mortar->GetComponent<SkillComponent>();
if (skillComponent) skillComponent->CastSkill(318);
} else if (timerName == "CineDone") {
GameMessages::SendNotifyClientObject(
self->GetObjectID(),
u"toggleInUse",
-1,
0,
LWOOBJID_EMPTY,
"",
UNASSIGNED_SYSTEM_ADDRESS
self->GetObjectID(), u"toggleInUse", -1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS
);
inUse = false;
}
}

View File

@@ -2,9 +2,10 @@
#include "Loot.h"
#include "GameMessages.h"
#include "Entity.h"
#include "eTerminateType.h"
void AgPicnicBlanket::OnUse(Entity* self, Entity* user) {
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
if (self->GetVar<bool>(u"active"))
return;
self->SetVar<bool>(u"active", true);

View File

@@ -49,7 +49,7 @@ void AgQbElevator::OnTimerDone(Entity* self, std::string timerName) {
} else if (timerName == "startKillTimer") {
killTimerStartup(self);
} else if (timerName == "KillTimer") {
self->Smash(self->GetObjectID(), VIOLENT);
self->Smash(self->GetObjectID(), eKillType::VIOLENT);
}
}

View File

@@ -2,6 +2,7 @@
#include "GameMessages.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eTerminateType.h"
void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) {
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());

View File

@@ -0,0 +1,78 @@
#include "ActNinjaSensei.h"
#include "Entity.h"
#include "EntityManager.h"
#include "GameMessages.h"
void ActNinjaSensei::OnStartup(Entity* self) {
auto students = EntityManager::Instance()->GetEntitiesInGroup(this->m_StudentGroup);
std::vector<Entity*> validStudents = {};
for (auto* student : students) {
if (student && student->GetLOT() == this->m_StudentLOT) validStudents.push_back(student);
}
self->SetVar(u"students", validStudents);
self->AddTimer("crane", 5);
}
void ActNinjaSensei::OnTimerDone(Entity* self, std::string timerName) {
auto students = self->GetVar<std::vector<Entity*>>(u"students");
if (students.empty()) return;
if (timerName == "crane") {
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"crane");
}
GameMessages::SendPlayAnimation(self, u"crane");
self->AddTimer("bow", 15.33);
}
if (timerName == "bow") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("tiger", 5);
}
if (timerName == "tiger") {
GameMessages::SendPlayAnimation(self, u"tiger");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"tiger");
}
GameMessages::SendPlayAnimation(self, u"tiger");
self->AddTimer("bow2", 15.33);
}
if (timerName == "bow2") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("mantis", 5);
}
if (timerName == "mantis") {
GameMessages::SendPlayAnimation(self, u"mantis");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"mantis");
}
GameMessages::SendPlayAnimation(self, u"mantis");
self->AddTimer("bow3", 15.3);
}
if (timerName == "bow3") {
GameMessages::SendPlayAnimation(self, u"bow");
for (auto student : students) {
if (student) GameMessages::SendPlayAnimation(student, u"bow");
}
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("repeat", 5);
}
if (timerName == "repeat") {
self->CancelAllTimers();
self->AddTimer("crane", 5);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class ActNinjaSensei : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
std::string m_StudentGroup = "Sensei_kids";
LOT m_StudentLOT = 2497;
};

View File

@@ -1,9 +1,10 @@
#include "ActNinjaTurret.h"
#include "eRebuildState.h"
void ActNinjaTurret::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"AmBuilt", true);
} else if (state == eRebuildState::REBUILD_RESETTING) {
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"AmBuilt", false);
}
}

View File

@@ -21,7 +21,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
auto* rebuildComponent = object->GetComponent<RebuildComponent>();
if (rebuildComponent->GetState() == REBUILD_COMPLETED) {
if (rebuildComponent->GetState() == eRebuildState::COMPLETED) {
indexCount++;
}
}
@@ -52,7 +52,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
}
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_RESETTING) {
if (state == eRebuildState::RESETTING) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {

View File

@@ -1,4 +1,5 @@
set(DSCRIPTS_SOURCES_AI_FV
set(DSCRIPTS_SOURCES_AI_FV
"ActNinjaSensei.cpp"
"ActNinjaTurret.cpp"
"FvFlyingCreviceDragon.cpp"
"FvDragonSmashingGolemQb.cpp"
@@ -15,4 +16,5 @@ set(DSCRIPTS_SOURCES_AI_FV
"FvPassThroughWall.cpp"
"FvBounceOverWall.cpp"
"FvMaelstromGeyser.cpp"
"TriggerGas.cpp"
PARENT_SCOPE)

View File

@@ -61,8 +61,8 @@ void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "reset") {
auto* rebuildComponent = self->GetComponent<RebuildComponent>();
if (rebuildComponent != nullptr && rebuildComponent->GetState() == REBUILD_OPEN) {
self->Smash(self->GetObjectID(), SILENT);
if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) {
self->Smash(self->GetObjectID(), eKillType::SILENT);
}
}
}

View File

@@ -1,6 +1,8 @@
#include "FvConsoleLeftQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -8,7 +10,7 @@ void FvConsoleLeftQuickbuild::OnStartup(Entity* self) {
}
void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
@@ -16,7 +18,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
}
} else if (state == REBUILD_RESETTING) {
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
@@ -43,5 +45,5 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -1,6 +1,8 @@
#include "FvConsoleRightQuickbuild.h"
#include "EntityManager.h"
#include "GameMessages.h"
#include "eTerminateType.h"
#include "eRebuildState.h"
void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
self->SetVar(u"IAmBuilt", false);
@@ -8,7 +10,7 @@ void FvConsoleRightQuickbuild::OnStartup(Entity* self) {
}
void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
@@ -16,7 +18,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
}
} else if (state == REBUILD_RESETTING) {
} else if (state == eRebuildState::RESETTING) {
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
@@ -43,5 +45,5 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
}
}
GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID());
}

View File

@@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "RenderComponent.h"
#include "Entity.h"
#include "eRebuildState.h"
void FvDragonSmashingGolemQb::OnStartup(Entity* self) {
self->AddTimer("GolemBreakTimer", 10.5f);
@@ -15,7 +16,7 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) {
}
void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::REBUILD_COMPLETED) {
if (state == eRebuildState::COMPLETED) {
RenderComponent::PlayAnimation(self, u"dragonsmash");
const auto dragonId = self->GetVar<LWOOBJID>(u"Dragon");

View File

@@ -56,7 +56,7 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st
object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0];
if (object != nullptr) {
object->Smash(self->GetObjectID(), SILENT);
object->Smash(self->GetObjectID(), eKillType::SILENT);
}
canisterSpawner->Reset();

View File

@@ -1,6 +1,7 @@
#include "FvPandaServer.h"
#include "PetComponent.h"
#include "Character.h"
#include "ePetTamingNotifyType.h"
void FvPandaServer::OnStartup(Entity* self) {
const auto* petComponent = self->GetComponent<PetComponent>();
@@ -10,12 +11,12 @@ void FvPandaServer::OnStartup(Entity* self) {
}
}
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) {
if (type == NOTIFY_TYPE_BEGIN) {
void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
if (type == ePetTamingNotifyType::BEGIN) {
self->CancelAllTimers();
} else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) {
} else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) {
self->Smash();
} else if (type == NOTIFY_TYPE_SUCCESS) {
} else if (type == ePetTamingNotifyType::SUCCESS) {
// TODO: Remove from groups
auto* character = tamer->GetCharacter();
@@ -29,7 +30,7 @@ void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "killSelf") {
const auto* petComponent = self->GetComponent<PetComponent>();
if (petComponent != nullptr && petComponent->GetOwner() == nullptr) {
self->Smash(self->GetObjectID(), SILENT);
self->Smash(self->GetObjectID(), eKillType::SILENT);
}
}
}

View File

@@ -3,6 +3,6 @@
class FvPandaServer : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override;
void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override;
void OnTimerDone(Entity* self, std::string timerName) override;
};

View File

@@ -0,0 +1,49 @@
#include "TriggerGas.h"
#include "InventoryComponent.h"
#include "SkillComponent.h"
#include "Entity.h"
#include "dLogger.h"
void TriggerGas::OnStartup(Entity* self) {
self->AddTimer(this->m_TimerName, this->m_Time);
}
void TriggerGas::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target->IsPlayer()) return;
auto players = self->GetVar<std::vector<Entity*>>(u"players");
players.push_back(target);
self->SetVar(u"players", players);
}
void TriggerGas::OnOffCollisionPhantom(Entity* self, Entity* target) {
auto players = self->GetVar<std::vector<Entity*>>(u"players");
if (!target->IsPlayer() || players.empty()) return;
auto position = std::find(players.begin(), players.end(), target);
if (position != players.end()) players.erase(position);
self->SetVar(u"players", players);
}
void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
if (timerName != this->m_TimerName) return;
auto players = self->GetVar<std::vector<Entity*>>(u"players");
for (auto player : players) {
if (player->GetIsDead() || !player){
auto position = std::find(players.begin(), players.end(), player);
if (position != players.end()) players.erase(position);
continue;
}
auto inventoryComponent = player->GetComponent<InventoryComponent>();
if (inventoryComponent) {
if (!inventoryComponent->IsEquipped(this->m_MaelstromHelmet)) {
auto* skillComponent = self->GetComponent<SkillComponent>();
if (skillComponent) {
skillComponent->CastSkill(this->m_FogDamageSkill, player->GetObjectID());
}
}
}
}
self->SetVar(u"players", players);
self->AddTimer(this->m_TimerName, this->m_Time);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "CppScripts.h"
class TriggerGas : public CppScripts::Script {
void OnStartup(Entity* self) override;
void OnCollisionPhantom(Entity* self, Entity* target) override;
void OnOffCollisionPhantom(Entity* self, Entity* target) override;
void OnTimerDone(Entity* self, std::string timerName) override;
private:
std::string m_TimerName = "gasTriggerDamage";
float m_Time = 3.0f;
uint32_t m_MaelstromHelmet = 3068;
uint32_t m_FogDamageSkill = 103;
};

View File

@@ -3,6 +3,7 @@
#include "Player.h"
#include "Character.h"
#include "dServer.h"
#include "eTerminateType.h"
void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* user) {
auto transferText = self->GetVar<std::u16string>(u"transferText");

View File

@@ -12,7 +12,7 @@ void LegoDieRoll::OnStartup(Entity* self) {
void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "DoneRolling") {
self->Smash(self->GetObjectID(), SILENT);
self->Smash(self->GetObjectID(), eKillType::SILENT);
} else if (timerName == "ThrowDice") {
int dieRoll = GeneralUtils::GenerateRandomNumber<int>(1, 6);

View File

@@ -1,6 +1,7 @@
#include "GfJailWalls.h"
#include "dZoneManager.h"
#include "GeneralUtils.h"
#include "eRebuildState.h"
void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) {
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));
@@ -15,7 +16,7 @@ void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) {
}
void GfJailWalls::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state != eRebuildState::REBUILD_RESETTING) return;
if (state != eRebuildState::RESETTING) return;
const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"Wall"));

View File

@@ -46,6 +46,6 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) {
// If the quick build expired and the treasure was not collected, hide the treasure
if (!treasure->GetIsDead()) {
treasure->Smash(self->GetObjectID(), SILENT);
treasure->Smash(self->GetObjectID(), eKillType::SILENT);
}
}

View File

@@ -2,12 +2,13 @@
#include "Character.h"
#include "eMissionState.h"
#include "Entity.h"
#include "ePlayerFlag.h"
void PirateRep::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
if (missionID == m_PirateRepMissionID && missionState >= eMissionState::READY_TO_COMPLETE) {
auto* character = target->GetCharacter();
if (character) {
character->SetPlayerFlag(ePlayerFlags::GF_PIRATE_REP, true);
character->SetPlayerFlag(ePlayerFlag::GF_PIRATE_REP, true);
}
}
}

View File

@@ -16,6 +16,7 @@
#include "eMissionTaskType.h"
#include "eReplicaComponentType.h"
#include "RenderComponent.h"
#include "eGameActivity.h"
void SGCannon::OnStartup(Entity* self) {
Game::logger->Log("SGCannon", "OnStartup");
@@ -103,7 +104,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
if (characterComponent != nullptr) {
characterComponent->SetIsRacing(true);
characterComponent->SetCurrentActivity(2);
characterComponent->SetCurrentActivity(eGameActivity::SHOOTING_GALLERY);
auto possessor = player->GetComponent<PossessorComponent>();
if (possessor) {
possessor->SetPossessable(self->GetObjectID());
@@ -135,38 +136,26 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
}
}
void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier,
const std::u16string& userData) {
void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
if (button == 1 && identifier == u"Shooting_Gallery_Stop") {
if (!player) return;
if (identifier == u"Scoreboardinfo") {
GameMessages::SendDisplayMessageBox(player->GetObjectID(), true,
dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(),
u"Shooting_Gallery_Retry", 2, u"Retry?",
u"", player->GetSystemAddress());
} else {
if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay")) || identifier == u"SG1" || button == 0) {
if (IsPlayerInActivity(self, player->GetObjectID())) return;
self->SetNetworkVar<bool>(ClearVariable, true);
StartGame(self);
} else if (button == 0 && ((identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay"))){
RemovePlayer(player->GetObjectID());
UpdatePlayer(self, player->GetObjectID(), true);
} else if (button == 1 && identifier == u"Shooting_Gallery_Exit") {
UpdatePlayer(self, player->GetObjectID(), true);
RemovePlayer(player->GetObjectID());
StopGame(self, true);
return;
}
if (identifier == u"Scoreboardinfo") {
GameMessages::SendDisplayMessageBox(player->GetObjectID(), true,
dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(),
u"Shooting_Gallery_Retry?", 2, u"Retry?",
u"", player->GetSystemAddress());
} else {
if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay"))
|| identifier == u"SG1" || button == 0) {
if (identifier == u"RePlay") {
static_cast<Player*>(player)->SendToZone(1300);
return;
}
self->SetNetworkVar<bool>(ClearVariable, true);
StartGame(self);
} else if (button == 1 && identifier == u"Shooting_Gallery_Exit") {
UpdatePlayer(self, player->GetObjectID(), true);
RemovePlayer(player->GetObjectID());
}
}
}
}
@@ -267,13 +256,17 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
if (self->GetVar<bool>(GameStartedVariable)) {
const auto spawnNumber = (uint32_t)std::stoi(name.substr(7));
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
if (activeSpawns.size() < spawnNumber) {
Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
return;
}
const auto& toSpawn = activeSpawns.at(spawnNumber);
const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1);
const auto* path = dZoneManager::Instance()->GetZone()->GetPath(
toSpawn.spawnPaths.at(pathIndex)
);
const auto* path = dZoneManager::Instance()->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex));
if (!path) {
Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
return;
}
auto info = EntityInfo{};
info.lot = toSpawn.lot;
@@ -294,32 +287,30 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self);
EntityManager::Instance()->ConstructEntity(enemy);
if (true) {
auto* movementAI = new MovementAIComponent(enemy, {});
auto* movementAI = new MovementAIComponent(enemy, {});
enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI);
enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI);
movementAI->SetSpeed(toSpawn.initialSpeed);
movementAI->SetCurrentSpeed(toSpawn.initialSpeed);
movementAI->SetHaltDistance(0.0f);
movementAI->SetSpeed(toSpawn.initialSpeed);
movementAI->SetCurrentSpeed(toSpawn.initialSpeed);
movementAI->SetHaltDistance(0.0f);
std::vector<NiPoint3> pathWaypoints;
std::vector<NiPoint3> pathWaypoints;
for (const auto& waypoint : path->pathWaypoints) {
pathWaypoints.push_back(waypoint.position);
}
if (GeneralUtils::GenerateRandomNumber<float_t>(0, 1) < 0.5f) {
std::reverse(pathWaypoints.begin(), pathWaypoints.end());
}
movementAI->SetPath(pathWaypoints);
enemy->AddDieCallback([this, self, enemy, name]() {
RegisterHit(self, enemy, name);
});
for (const auto& waypoint : path->pathWaypoints) {
pathWaypoints.push_back(waypoint.position);
}
if (GeneralUtils::GenerateRandomNumber<float_t>(0, 1) < 0.5f) {
std::reverse(pathWaypoints.begin(), pathWaypoints.end());
}
movementAI->SetPath(pathWaypoints);
enemy->AddDieCallback([this, self, enemy, name]() {
RegisterHit(self, enemy, name);
});
// Save the enemy and tell it to start pathing
if (enemy != nullptr) {
const_cast<std::vector<LWOOBJID>&>(self->GetVar<std::vector<LWOOBJID>>(SpawnedObjects)).push_back(enemy->GetObjectID());
@@ -338,6 +329,7 @@ SGCannon::OnActivityTimerUpdate(Entity* self, const std::string& name, float_t t
}
void SGCannon::StartGame(Entity* self) {
if (self->GetVar<bool>(GameStartedVariable)) return;
self->SetNetworkVar<uint32_t>(TimeLimitVariable, self->GetVar<uint32_t>(TimeLimitVariable));
self->SetNetworkVar<bool>(AudioStartIntroVariable, true);
self->SetVar<LOT>(CurrentRewardVariable, LOT_NULL);
@@ -444,6 +436,14 @@ void SGCannon::RemovePlayer(LWOOBJID playerID) {
}
}
void SGCannon::OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled){
if (canceled){
StopGame(self, canceled);
RemovePlayer(player);
}
}
void SGCannon::StartChargedCannon(Entity* self, uint32_t optionalTime) {
optionalTime = optionalTime == 0 ? constants.chargedTime : optionalTime;
self->SetVar<bool>(SuperChargePausedVariable, false);
@@ -571,13 +571,13 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
auto* inventory = player->GetComponent<InventoryComponent>();
if (inventory != nullptr) {
for (const auto rewardLot : self->GetVar<std::vector<LOT>>(RewardsVariable)) {
inventory->AddItem(rewardLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS);
inventory->AddItem(rewardLot, 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS);
}
}
self->SetNetworkVar<std::u16string>(u"UI_Rewards",
GeneralUtils::to_u16string(self->GetVar<uint32_t>(TotalScoreVariable)) + u"_0_0_0_0_0_0"
);
);
GameMessages::SendRequestActivitySummaryLeaderboardData(
player->GetObjectID(),

View File

@@ -63,12 +63,11 @@ public:
void OnStartup(Entity* self) override;
void OnPlayerLoaded(Entity* self, Entity* player) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1,
int32_t value2, const std::u16string& stringValue) override;
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier,
const std::u16string& userData) override;
void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) override;
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) override;
void OnActivityTimerDone(Entity* self, const std::string& name) override;
void OnActivityTimerUpdate(Entity* self, const std::string& name, float_t timeRemaining, float_t elapsedTime) override;
void OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override;
private:
static std::vector<std::vector<SGEnemy>> GetWaves();
static SGConstants GetConstants();

View File

@@ -21,7 +21,7 @@ void NsConcertInstrument::OnStartup(Entity* self) {
}
void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == REBUILD_RESETTING || state == REBUILD_OPEN) {
if (state == eRebuildState::RESETTING || state == eRebuildState::OPEN) {
self->SetVar<LWOOBJID>(u"activePlayer", LWOOBJID_EMPTY);
}
}
@@ -97,7 +97,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) {
if (rebuildComponent != nullptr)
rebuildComponent->ResetRebuild(false);
self->Smash(self->GetObjectID(), VIOLENT);
self->Smash(self->GetObjectID(), eKillType::VIOLENT);
self->SetVar<LWOOBJID>(u"activePlayer", LWOOBJID_EMPTY);
} else if (activePlayer != nullptr && name == "achievement") {
auto* missionComponent = activePlayer->GetComponent<MissionComponent>();
@@ -200,7 +200,7 @@ void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) {
// Equip the left hand instrument
const auto leftInstrumentLot = instrumentLotLeft.find(GetInstrumentLot(self))->second;
if (leftInstrumentLot != LOT_NULL) {
inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
auto* leftInstrument = inventory->FindItemByLot(leftInstrumentLot, TEMP_ITEMS);
leftInstrument->Equip();
}
@@ -208,7 +208,7 @@ void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) {
// Equip the right hand instrument
const auto rightInstrumentLot = instrumentLotRight.find(GetInstrumentLot(self))->second;
if (rightInstrumentLot != LOT_NULL) {
inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false);
auto* rightInstrument = inventory->FindItemByLot(rightInstrumentLot, TEMP_ITEMS);
rightInstrument->Equip();
}

View File

@@ -58,7 +58,7 @@ void NsConcertQuickBuild::OnStartup(Entity* self) {
// Destroys the quick build after a while if it wasn't built
self->AddCallbackTimer(resetActivatorTime, [self]() {
self->SetNetworkVar<float>(u"startEffect", -1.0f);
self->Smash(self->GetObjectID(), SILENT);
self->Smash(self->GetObjectID(), eKillType::SILENT);
});
}

View File

@@ -3,6 +3,7 @@
#include "MissionComponent.h"
#include "Character.h"
#include "eReplicaComponentType.h"
#include "ePlayerFlag.h"
void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID, Entity* player, int reward) {
if (missionID != 474) return;
@@ -10,7 +11,7 @@ void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID,
if (reward != LOT_NULL) {
std::vector<int> factionMissions;
int celebrationID = -1;
int flagID = -1;
int32_t flagID = -1;
if (reward == 6980) {
// Venture League
@@ -41,7 +42,7 @@ void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID,
}
if (flagID != -1) {
player->GetCharacter()->SetPlayerFlag(ePlayerFlags::JOINED_A_FACTION, true);
player->GetCharacter()->SetPlayerFlag(ePlayerFlag::JOINED_A_FACTION, true);
player->GetCharacter()->SetPlayerFlag(flagID, true);
}

View File

@@ -39,7 +39,7 @@ void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int mission
}
}
uint32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
int32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
switch (missionID) {
case 872:
return 97;

View File

@@ -4,5 +4,5 @@
class AgPropguards : public CppScripts::Script {
void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override;
private:
static uint32_t GetFlagForMission(uint32_t missionID);
static int32_t GetFlagForMission(uint32_t missionID);
};

View File

@@ -1,3 +1,5 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialImaginePowerupSpawner.cpp"
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
"SpecialSpeedBuffSpawner.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,16 @@
#include "SpecialCoinSpawner.h"
#include "CharacterComponent.h"
void SpecialCoinSpawner::OnStartup(Entity* self) {
self->SetProximityRadius(1.5f, "powerupEnter");
}
void SpecialCoinSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) {
if (name != "powerupEnter" && status != "ENTER") return;
if (!entering->IsPlayer()) return;
auto character = entering->GetCharacter();
if (!character) return;
GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true);
character->SetCoins(character->GetCoins() + this->m_CurrencyDenomination, eLootSourceType::CURRENCY);
self->Smash(entering->GetObjectID(), eKillType::SILENT);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "CppScripts.h"
class SpecialCoinSpawner : public CppScripts::Script {
public:
SpecialCoinSpawner(uint32_t CurrencyDenomination) {
m_CurrencyDenomination = CurrencyDenomination;
};
void OnStartup(Entity* self) override;
void OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) override;
private:
int32_t m_CurrencyDenomination = 0;
};

View File

@@ -1,48 +0,0 @@
#include "SpecialImaginePowerupSpawner.h"
#include "GameMessages.h"
#include "SkillComponent.h"
#include "DestroyableComponent.h"
#include "EntityManager.h"
#include "eReplicaComponentType.h"
void SpecialImaginePowerupSpawner::OnStartup(Entity* self) {
self->SetProximityRadius(1.5f, "powerupEnter");
self->SetVar(u"bIsDead", false);
}
void SpecialImaginePowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) {
if (name != "powerupEnter" && status != "ENTER") {
return;
}
if (entering->GetLOT() != 1) {
return;
}
if (self->GetVar<bool>(u"bIsDead")) {
return;
}
GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true);
SkillComponent* skillComponent;
if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) {
return;
}
const auto source = entering->GetObjectID();
skillComponent->CalculateBehavior(13, 20, source);
DestroyableComponent* destroyableComponent;
if (!self->TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) {
return;
}
self->SetVar(u"bIsDead", true);
self->AddCallbackTimer(1.0f, [self]() {
EntityManager::Instance()->ScheduleForKill(self);
});
}

View File

@@ -0,0 +1,26 @@
#include "SpecialPowerupSpawner.h"
#include "GameMessages.h"
#include "SkillComponent.h"
#include "EntityManager.h"
#include "eReplicaComponentType.h"
void SpecialPowerupSpawner::OnStartup(Entity* self) {
self->SetProximityRadius(1.5f, "powerupEnter");
self->SetVar(u"bIsDead", false);
}
void SpecialPowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) {
if (name != "powerupEnter" && status != "ENTER") return;
if (!entering->IsPlayer()) return;
if (self->GetVar<bool>(u"bIsDead")) return;
GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true);
auto skillComponent = self->GetComponent<SkillComponent>();
if (!skillComponent) return;
skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID());
self->SetVar(u"bIsDead", true);
self->Smash(entering->GetObjectID(), eKillType::SILENT);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "CppScripts.h"
class SpecialPowerupSpawner : public CppScripts::Script {
public:
SpecialPowerupSpawner(uint32_t skillId) {
m_SkillId = skillId;
};
void OnStartup(Entity* self) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
private:
uint32_t m_SkillId = 0;
};

View File

@@ -0,0 +1,26 @@
#include "SpecialSpeedBuffSpawner.h"
#include "GameMessages.h"
#include "SkillComponent.h"
#include "EntityManager.h"
#include "eReplicaComponentType.h"
void SpecialSpeedBuffSpawner::OnStartup(Entity* self) {
self->SetProximityRadius(1.5f, "powerupEnter");
self->SetVar(u"bIsDead", false);
}
void SpecialSpeedBuffSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) {
if (name != "powerupEnter" && status != "ENTER") return;
if (!entering->IsPlayer()) return;
if (self->GetVar<bool>(u"bIsDead")) return;
GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true);
auto skillComponent = entering->GetComponent<SkillComponent>();
if (!skillComponent) return;
skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID());
self->SetVar(u"bIsDead", true);
self->Smash(entering->GetObjectID(), eKillType::SILENT);
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "CppScripts.h"
class SpecialSpeedBuffSpawner : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
private:
uint32_t m_SkillId = 500;
};

View File

@@ -1,4 +1,11 @@
set(DSCRIPTS_SOURCES_AI_WILD
set(DSCRIPTS_SOURCES_AI_WILD
"AllCrateChicken.cpp"
"WildAmbients.cpp"
"WildAmbientCrab.cpp"
"WildAndScared.cpp"
"WildGfGlowbug.cpp"
"WildNinjaBricks.cpp"
"WildNinjaStudent.cpp"
"WildNinjaSensei.cpp"
"WildPants.cpp"
PARENT_SCOPE)

View File

@@ -0,0 +1,27 @@
#include "WildAmbientCrab.h"
#include "GameMessages.h"
void WildAmbientCrab::OnStartup(Entity* self){
self->SetVar(u"flipped", true);
GameMessages::SendPlayAnimation(self, u"idle");
}
void WildAmbientCrab::OnUse(Entity* self, Entity* user) {
auto flipped = self->GetVar<bool>(u"flipped");
if (flipped) {
self->AddTimer("Flipping", 0.6f);
GameMessages::SendPlayAnimation(self, u"flip-over");
self->SetVar(u"flipped", false);
} else if (!flipped) {
self->AddTimer("Flipback", 0.8f);
GameMessages::SendPlayAnimation(self, u"flip-back");
self->SetVar(u"flipped", true);
}
}
void WildAmbientCrab::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "Flipping") GameMessages::SendPlayAnimation(self, u"over-idle");
else if (timerName == "Flipback") GameMessages::SendPlayAnimation(self, u"idle");
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildAmbientCrab final : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnTimerDone(Entity* self, std::string timerName) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -0,0 +1,6 @@
#include "WildAndScared.h"
#include "GameMessages.h"
void WildAndScared::OnUse(Entity* self, Entity* user) {
GameMessages::SendPlayAnimation(self, u"scared");
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "CppScripts.h"
class WildAndScared : public CppScripts::Script {
public:
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -0,0 +1,28 @@
#include "WildGfGlowbug.h"
#include "GameMessages.h"
void WildGfGlowbug::OnStartup(Entity* self){
self->SetVar(u"switch", false);
}
void WildGfGlowbug::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
if (args == "physicsReady") {
auto switchState = self->GetVar<bool>(u"switch");
if (!switchState) {
GameMessages::SendStopFXEffect(self, true, "glowlight");
} else if (switchState) {
GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY);
}
}
}
void WildGfGlowbug::OnUse(Entity* self, Entity* user) {
auto switchState = self->GetVar<bool>(u"switch");
if (switchState) {
GameMessages::SendStopFXEffect(self, true, "glowlight");
self->SetVar(u"switch", false);
} else if (!switchState) {
GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY);
self->SetVar(u"switch", true);
}
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildGfGlowbug : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
void OnUse(Entity* self, Entity* user) override;
};

View File

@@ -0,0 +1,13 @@
#include "WildNinjaBricks.h"
#include "Entity.h"
void WildNinjaBricks::OnStartup(Entity* self) {
self->AddToGroup("Ninjastuff");
}
void WildNinjaBricks::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildNinjaBricks : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
};

View File

@@ -0,0 +1,36 @@
#include "WildNinjaSensei.h"
#include "Entity.h"
void WildNinjaSensei::OnStartup(Entity* self) {
GameMessages::SendPlayAnimation(self, u"bow");
self->AddTimer("CraneStart", 5);
}
void WildNinjaSensei::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "CraneStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Crane");
self->AddTimer("Bow", 15.5f);
self->AddTimer("TigerStart", 25);
GameMessages::SendPlayAnimation(self, u"crane");
} else if (timerName == "TigerStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"bow");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Tiger");
self->AddTimer("Bow", 15.5f);
self->AddTimer("MantisStart", 25);
GameMessages::SendPlayAnimation(self, u"tiger");
} else if (timerName == "MantisStart") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"tiger");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Mantis");
self->AddTimer("Bow", 15.5f);
self->AddTimer("CraneStart", 25);
GameMessages::SendPlayAnimation(self, u"mantis");
} else if (timerName == "Bow") {
auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff");
for (auto ninja : ninjas) ninja->NotifyObject(self, "Bow");
GameMessages::SendPlayAnimation(self, u"bow");
}
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildNinjaSensei : public CppScripts::Script {
public:
void OnStartup(Entity* self);
void OnTimerDone(Entity* self, std::string timerName);
};

View File

@@ -0,0 +1,14 @@
#include "WildNinjaStudent.h"
#include "GameMessages.h"
void WildNinjaStudent::OnStartup(Entity* self) {
self->AddToGroup("Ninjastuff");
GameMessages::SendPlayAnimation(self, u"bow");
}
void WildNinjaStudent::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane");
else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger");
else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis");
else if (name == "Bow") GameMessages::SendPlayAnimation(self, u"bow");
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildNinjaStudent : public CppScripts::Script {
public:
void OnStartup(Entity* self) override;
void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override;
};

View File

@@ -0,0 +1,10 @@
#include "WildPants.h"
#include "GameMessages.h"
void WildPants::OnStartup(Entity* self) {
self->SetProximityRadius(5, "scardyPants");
}
void WildPants::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
if (status == "ENTER") GameMessages::SendPlayAnimation(self, u"scared");
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include "CppScripts.h"
class SpecialImaginePowerupSpawner final : public CppScripts::Script
class WildPants : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;