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 1 commit
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
5 changes: 3 additions & 2 deletions dScripts/CppScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
// pickups
#include "SpecialCoinSpawner.h"
#include "SpecialPowerupSpawner.h"
#include "SpecialSpeedBuffSpawner.h"

// Wild Scripts
#include "WildAndScared.h"
Expand Down Expand Up @@ -893,9 +894,9 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
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);
script = new SpecialPowerupSpawner(747);
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua")
script = new SpecialPowerupSpawner(500);
script = new SpecialSpeedBuffSpawner();

// Wild
if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua")
Expand Down
1 change: 1 addition & 0 deletions dScripts/ai/SPEC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
"SpecialSpeedBuffSpawner.cpp"
PARENT_SCOPE)
5 changes: 3 additions & 2 deletions dScripts/ai/SPEC/SpecialPowerupSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ void SpecialPowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, co

GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true);

SkillComponent* skillComponent;
if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) return;
auto skillComponent = self->GetComponent<SkillComponent>();
if (!skillComponent) return;
Game::logger->Log("SpecialPowerupSpawner", "cast skill %i on %llu", this->m_SkillId, entering->GetObjectID());
aronwk-aaron marked this conversation as resolved.
Show resolved Hide resolved
skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID());

self->SetVar(u"bIsDead", true);
Expand Down
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);
}
10 changes: 10 additions & 0 deletions dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h
Original file line number Diff line number Diff line change
@@ -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;
};