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

@@ -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

@@ -0,0 +1,9 @@
#pragma once
#include "CppScripts.h"
class WildPants : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override;
};