mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 17:58:20 +00:00
Merge pull request #1050 from DarkflameUniverse/pickup-scripts
Implements all the pickup scripts
This commit is contained in:
commit
9c721abebb
@ -160,7 +160,6 @@
|
||||
#include "AgSalutingNpcs.h"
|
||||
#include "BossSpiderQueenEnemyServer.h"
|
||||
#include "RockHydrantSmashable.h"
|
||||
#include "SpecialImaginePowerupSpawner.h"
|
||||
|
||||
// Misc Scripts
|
||||
#include "ExplodingAsset.h"
|
||||
@ -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"
|
||||
@ -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")
|
||||
@ -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")
|
||||
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();
|
||||
|
@ -1,3 +1,5 @@
|
||||
set(DSCRIPTS_SOURCES_AI_SPEC
|
||||
"SpecialImaginePowerupSpawner.cpp"
|
||||
"SpecialCoinSpawner.cpp"
|
||||
"SpecialPowerupSpawner.cpp"
|
||||
"SpecialSpeedBuffSpawner.cpp"
|
||||
PARENT_SCOPE)
|
||||
|
16
dScripts/ai/SPEC/SpecialCoinSpawner.cpp
Normal file
16
dScripts/ai/SPEC/SpecialCoinSpawner.cpp
Normal 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::LOOT_SOURCE_CURRENCY);
|
||||
self->Smash(entering->GetObjectID(), eKillType::SILENT);
|
||||
}
|
13
dScripts/ai/SPEC/SpecialCoinSpawner.h
Normal file
13
dScripts/ai/SPEC/SpecialCoinSpawner.h
Normal 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;
|
||||
};
|
@ -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);
|
||||
});
|
||||
}
|
26
dScripts/ai/SPEC/SpecialPowerupSpawner.cpp
Normal file
26
dScripts/ai/SPEC/SpecialPowerupSpawner.cpp
Normal 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);
|
||||
}
|
13
dScripts/ai/SPEC/SpecialPowerupSpawner.h
Normal file
13
dScripts/ai/SPEC/SpecialPowerupSpawner.h
Normal 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;
|
||||
};
|
26
dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp
Normal file
26
dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp
Normal 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);
|
||||
}
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user