fix scripts

split speed out to use target as caster
fix armor skill
This commit is contained in:
Aaron Kimbre 2023-04-09 13:21:57 -05:00
parent bed269ffbe
commit 09e9bb2c15
5 changed files with 43 additions and 4 deletions

View File

@ -297,6 +297,7 @@
// pickups
#include "SpecialCoinSpawner.h"
#include "SpecialPowerupSpawner.h"
#include "SpecialSpeedBuffSpawner.h"
// Wild Scripts
#include "WildAndScared.h"
@ -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")
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")

View File

@ -1,4 +1,5 @@
set(DSCRIPTS_SOURCES_AI_SPEC
"SpecialCoinSpawner.cpp"
"SpecialPowerupSpawner.cpp"
"SpecialSpeedBuffSpawner.cpp"
PARENT_SCOPE)

View File

@ -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());
skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID());
self->SetVar(u"bIsDead", true);

View 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);
}

View File

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