implement rest of equipment scripts (#1714)

This commit is contained in:
David Markowitz
2025-01-03 14:44:20 -08:00
committed by GitHub
parent c8fcb3788d
commit fb32534ae3
15 changed files with 188 additions and 30 deletions

View File

@@ -334,6 +334,8 @@
#include "AgSpiderBossMessage.h"
#include "GfRaceInstancer.h"
#include "NsRaceServer.h"
#include "TrialFactionArmorServer.h"
#include "ImaginationBackPack.h"
#include <map>
#include <string>
@@ -700,6 +702,8 @@ namespace {
{"scripts\\ai\\RACING\\TRACK_GF\\GF_RACE_SERVER.lua", []() {return new GfRaceServer();}},
{"scripts\\ai\\RACING\\TRACK_FV\\FV_RACE_SERVER.lua", []() {return new FvRaceServer();}},
{"scripts\\ai\\RACING\\OBJECTS\\VEHICLE_DEATH_TRIGGER_WATER_SERVER.lua", []() {return new VehicleDeathTriggerWaterServer();}},
{"scripts\\equipmenttriggers\\L_TRIAL_FACTION_ARMOR_SERVER.lua", []() {return new TrialFactionArmorServer();}},
{"scripts\\equipmenttriggers\\ImaginationBackPack.lua", []() {return new ImaginationBackPack();}},
};

View File

@@ -186,6 +186,8 @@ namespace CppScripts {
*/
virtual void NotifyHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {};
virtual void NotifyPlayerResurrectionFinished(Entity& self, GameMessages::PlayerResurrectionFinished& msg) {};
/**
* Invoked when a player has responsed to a mission.
*

View File

@@ -1,5 +1,7 @@
set(DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS
"CoilBackpackBase.cpp")
"CoilBackpackBase.cpp"
"ImaginationBackPack.cpp"
"TrialFactionArmorServer.cpp")
add_library(dScriptsEquipmentTriggers OBJECT ${DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS})
target_include_directories(dScriptsEquipmentTriggers PUBLIC ".")

View File

@@ -0,0 +1,22 @@
#include "ImaginationBackPack.h"
#include "SkillComponent.h"
void ImaginationBackPack::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {
LOG("Subscribing to PlayerResurrectionFinished");
itemOwner->Subscribe(itemObjId, this, "PlayerResurrectionFinished");
}
void ImaginationBackPack::NotifyPlayerResurrectionFinished(Entity& self, GameMessages::PlayerResurrectionFinished& msg) {
LOG("PlayerResurrectionFinished");
auto* skillComponent = self.GetComponent<SkillComponent>();
if (!skillComponent) return;
LOG("Casting skill 1334");
skillComponent->CastSkill(1334);
}
void ImaginationBackPack::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {
LOG("Unsubscribing from PlayerResurrectionFinished");
itemOwner->Unsubscribe(itemObjId, "PlayerResurrectionFinished");
}

View File

@@ -0,0 +1,13 @@
#ifndef IMAGINATIONBACKPACK_H
#define IMAGINATIONBACKPACK_H
#include "CppScripts.h"
class ImaginationBackPack : public CppScripts::Script {
public:
void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) override;
void NotifyPlayerResurrectionFinished(Entity& self, GameMessages::PlayerResurrectionFinished& msg) override;
void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) override;
};
#endif //!IMAGINATIONBACKPACK_H

View File

@@ -0,0 +1,13 @@
#ifndef __OBYXSHARDPACK__H__
#define __OBYXSHARDPACK__H__
#include "CoilBackpackBase.h"
class ObyxShardPack : public CoilBackpackBase {
public:
ObyxShardPack() : CoilBackpackBase(skillId) {};
private:
static const uint32_t skillId = 1751;
};
#endif //!__OBYXSHARDPACK__H__

View File

@@ -0,0 +1,13 @@
#ifndef __RUBYSHARDPACK__H__
#define __RUBYSHARDPACK__H__
#include "CoilBackpackBase.h"
class RubyShardPack : public CoilBackpackBase {
public:
RubyShardPack() : CoilBackpackBase(skillId) {};
private:
static const uint32_t skillId = 1750;
};
#endif //!__RUBYSHARDPACK__H__

View File

@@ -0,0 +1,27 @@
#include "TrialFactionArmorServer.h"
#include "Character.h"
#include "ePlayerFlag.h"
#include "DestroyableComponent.h"
void TrialFactionArmorServer::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) {
auto* character = itemOwner->GetCharacter();
if (!character) return;
auto flag = character->GetPlayerFlag(ePlayerFlag::EQUPPED_TRIAL_FACTION_GEAR);
if (!flag) {
character->SetPlayerFlag(ePlayerFlag::EQUPPED_TRIAL_FACTION_GEAR, true);
// technically a TimerWithCancel but our current implementation doesnt support this.
itemOwner->AddCallbackTimer(1.0f, [itemOwner]() {
auto* destroyableComponent = itemOwner->GetComponent<DestroyableComponent>();
if (!destroyableComponent) return;
destroyableComponent->SetHealth(destroyableComponent->GetMaxHealth());
destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor());
destroyableComponent->SetImagination(destroyableComponent->GetMaxImagination());
Game::entityManager->SerializeEntity(itemOwner);
});
}
}

View File

@@ -0,0 +1,11 @@
#ifndef TRIALFACTIONARMORSERVER_
#define TRIALFACTIONARMORSERVER_
#include "CppScripts.h"
class TrialFactionArmorServer : public CppScripts::Script {
public:
void OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) override;
};
#endif //!TRIALFACTIONARMORSERVER_