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 all 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
38 changes: 35 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,11 @@
// WBL scripts
#include "WblGenericZone.h"

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

// Wild Scripts
#include "WildAndScared.h"
#include "WildGfGlowbug.h"
Expand Down Expand Up @@ -377,8 +381,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 @@ -866,6 +868,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(747);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua")
script = new SpecialSpeedBuffSpawner();

// Wild
if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua")
script = new WildAndScared();
Expand Down
6 changes: 4 additions & 2 deletions dScripts/ai/SPEC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialImaginePowerupSpawner.cpp"
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
"SpecialSpeedBuffSpawner.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);

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);
}
13 changes: 13 additions & 0 deletions dScripts/ai/SPEC/SpecialPowerupSpawner.h
Original file line number Diff line number Diff line change
@@ -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;
};
26 changes: 26 additions & 0 deletions dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once
#include "CppScripts.h"

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