Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements all the pickup scripts #1050

Merged
merged 8 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions dScripts/CppScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
#include "AgSalutingNpcs.h"
#include "BossSpiderQueenEnemyServer.h"
#include "RockHydrantSmashable.h"
#include "SpecialImaginePowerupSpawner.h"

// Misc Scripts
#include "ExplodingAsset.h"
Expand Down Expand Up @@ -295,6 +294,10 @@
// WBL scripts
#include "WblGenericZone.h"

// pickups
#include "SpecialCoinSpawner.h"
#include "SpecialPowerupSpawner.h"

//Big bad global bc this is a namespace and not a class:
InvalidScript* invalidToReturn = new InvalidScript();
std::map<std::string, CppScripts::Script*> m_Scripts;
Expand Down Expand Up @@ -371,8 +374,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
script = new RemoveRentalGear();
else if (scriptName == "scripts\\02_server\\Map\\AG\\L_NPC_NJ_ASSISTANT_SERVER.lua")
script = new NpcNjAssistantServer();
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua")
script = new SpecialImaginePowerupSpawner();
else if (scriptName == "scripts\\ai\\AG\\L_AG_SALUTING_NPCS.lua")
script = new AgSalutingNpcs();
else if (scriptName == "scripts\\ai\\AG\\L_AG_JET_EFFECT_SERVER.lua")
Expand Down Expand Up @@ -860,6 +861,36 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua")
script = new WblGenericZone();

// pickups
if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_BRONZE-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(1);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_GOLD-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(10000);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_SILVER-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(100);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_BRONZE-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(10);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_GOLD-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(100000);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_SILVER-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(1000);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_BRONZE-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(25);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_GOLD-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(250000);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_SILVER-COIN-SPAWNER.lua")
script = new SpecialCoinSpawner(2500);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua")
script = new SpecialPowerupSpawner(13);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER-2PT.lua")
script = new SpecialPowerupSpawner(129);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_LIFE-POWERUP-SPAWNER.lua")
script = new SpecialPowerupSpawner(5);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_ARMOR-POWERUP-SPAWNER.lua")
aronwk-aaron marked this conversation as resolved.
Show resolved Hide resolved
script = new SpecialPowerupSpawner(80);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua")
script = new SpecialPowerupSpawner(500);

// handle invalid script reporting if the path is greater than zero and it's not an ignored script
// information not really needed for sys admins but is for developers
else if (script == invalidToReturn) {
Expand Down
5 changes: 3 additions & 2 deletions dScripts/ai/SPEC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialImaginePowerupSpawner.cpp"
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
PARENT_SCOPE)
16 changes: 16 additions & 0 deletions dScripts/ai/SPEC/SpecialCoinSpawner.cpp
Original file line number Diff line number Diff line change
@@ -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::LOOT_SOURCE_CURRENCY);
self->Smash(entering->GetObjectID(), eKillType::SILENT);
}
13 changes: 13 additions & 0 deletions dScripts/ai/SPEC/SpecialCoinSpawner.h
Original file line number Diff line number Diff line change
@@ -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;
};
48 changes: 0 additions & 48 deletions dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp

This file was deleted.

26 changes: 26 additions & 0 deletions dScripts/ai/SPEC/SpecialPowerupSpawner.cpp
Original file line number Diff line number Diff line change
@@ -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);

SkillComponent* skillComponent;
aronwk-aaron marked this conversation as resolved.
Show resolved Hide resolved
if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) return;
skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID());

self->SetVar(u"bIsDead", true);
self->Smash(entering->GetObjectID(), eKillType::SILENT);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#pragma once
#include "CppScripts.h"

class SpecialImaginePowerupSpawner final : public CppScripts::Script
{
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;
};