-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tested that the message now shows up when hitting the survival spider entrance area
- Loading branch information
Showing
6 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "AgSpiderBossMessage.h" | ||
|
||
#include "Entity.h" | ||
#include "GameMessages.h" | ||
|
||
#include "RenderComponent.h" | ||
|
||
Box AgSpiderBossMessage::GetBox(Entity* self) const { | ||
return self->GetVar<Box>(u"box"); | ||
} | ||
|
||
void AgSpiderBossMessage::SetBox(Entity* self, const Box& box) const { | ||
self->SetVar(u"box", box); | ||
} | ||
|
||
void AgSpiderBossMessage::MakeBox(Entity* self) const { | ||
auto box = GetBox(self); | ||
if (box.boxTarget == LWOOBJID_EMPTY || box.isDisplayed || box.boxSelf == LWOOBJID_EMPTY) return; | ||
|
||
box.isDisplayed = true; | ||
SetBox(self, box); | ||
self->AddTimer("BoxTimer", box.boxTime); | ||
|
||
const auto* const tgt = Game::entityManager->GetEntity(box.boxTarget); | ||
if (!tgt) return; | ||
GameMessages::DisplayTooltip tooltip; | ||
tooltip.target = tgt->GetObjectID(); | ||
tooltip.sysAddr = tgt->GetSystemAddress(); | ||
tooltip.show = true; | ||
tooltip.text = box.boxText; | ||
tooltip.time = box.boxTime * 1000; // to ms | ||
tooltip.Send(); | ||
} | ||
|
||
void AgSpiderBossMessage::OnCollisionPhantom(Entity* self, Entity* target) { | ||
if (!target || !target->IsPlayer()) return; | ||
|
||
auto box = GetBox(self); | ||
// knockback the target | ||
auto forward = target->GetRotation().GetForwardVector(); | ||
box.boxTarget = target->GetObjectID(); | ||
GameMessages::SendPlayFXEffect(target->GetObjectID(), 1378, u"create", "pushBack"); | ||
RenderComponent::PlayAnimation(target, "knockback-recovery"); | ||
forward.y += 15; | ||
forward.x *= 100; | ||
forward.z *= 100; | ||
GameMessages::SendKnockback(target->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 0, forward); | ||
|
||
if (box.isTouch || box.isDisplayed) return; | ||
box.boxSelf = self->GetObjectID(); | ||
box.isTouch = true; | ||
box.boxText = u"%[SPIDER_CAVE_MESSAGE]"; | ||
SetBox(self, box); | ||
self->AddTimer("EventTimer", 0.1f); | ||
} | ||
|
||
void AgSpiderBossMessage::OnOffCollisionPhantom(Entity* self, Entity* target) { | ||
if (!target) return; | ||
auto box = GetBox(self); | ||
box.isTouch = false; | ||
box.Reset(); | ||
SetBox(self, box); | ||
} | ||
|
||
void AgSpiderBossMessage::OnTimerDone(Entity* self, std::string timerName) { | ||
if (timerName == "BoxTimer") { | ||
auto box = GetBox(self); | ||
box.isDisplayed = false; | ||
SetBox(self, box); | ||
ResetBox(self); | ||
} else if (timerName == "EventTimer") { | ||
auto box = GetBox(self); | ||
MakeBox(self); | ||
} | ||
} | ||
|
||
void AgSpiderBossMessage::ResetBox(Entity* self) const { | ||
auto box = GetBox(self); | ||
box.Reset(); | ||
SetBox(self, box); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef AGSPIDERBOSSMESSAGE_H | ||
#define AGSPIDERBOSSMESSAGE_H | ||
|
||
#include "CppScripts.h" | ||
|
||
struct Box { | ||
LWOOBJID boxTarget{}; | ||
bool isDisplayed{}; | ||
bool isTouch{}; | ||
bool isFirst{}; | ||
LWOOBJID boxSelf{}; | ||
std::u16string boxText{}; | ||
int32_t boxTime{ 1 }; | ||
|
||
void Reset() { | ||
boxTarget = LWOOBJID_EMPTY; | ||
isDisplayed = false; | ||
isTouch = false; | ||
isFirst = false; | ||
boxSelf = LWOOBJID_EMPTY; | ||
boxText.clear(); | ||
boxTime = 1; | ||
} | ||
}; | ||
|
||
class AgSpiderBossMessage : public CppScripts::Script { | ||
public: | ||
Box GetBox(Entity* self) const; | ||
void SetBox(Entity* self, const Box& box) const; | ||
void MakeBox(Entity* self) const; | ||
void OnCollisionPhantom(Entity* self, Entity* target) override; | ||
void OnOffCollisionPhantom(Entity* self, Entity* target) override; | ||
void OnTimerDone(Entity* self, std::string timerName) override; | ||
void ResetBox(Entity* self) const; | ||
}; | ||
|
||
#endif //!AGSPIDERBOSSMESSAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters