mirror of
https://github.com/brues-code/nampower.git
synced 2026-09-30 18:50:00 +00:00
Merge pull request 'New event fo begin casting' (#12) from Mats391/nampower:BeginCastEvent into master
Reviewed-on: https://gitea.com/avitasia/nampower/pulls/12
This commit is contained in:
@@ -7,6 +7,7 @@ For custom Lua functions, see [SCRIPTS.md](SCRIPTS.md). For general usage inform
|
||||
## Table of Contents
|
||||
- [SPELL_QUEUE_EVENT](#spell_queue_event)
|
||||
- [SPELL_CAST_EVENT](#spell_cast_event)
|
||||
- [SPELL_BEGIN_CAST_EVENT](#spell_begin_cast_event)
|
||||
- [SPELL_DAMAGE_EVENT_SELF and SPELL_DAMAGE_EVENT_OTHER](#spell_damage_event_self-and-spell_damage_event_other)
|
||||
- [Buff/Debuff Events](#buffdebuff-events)
|
||||
- [AURA_CAST_ON_SELF and AURA_CAST_ON_OTHER](#aura_cast_on_self-and-aura_cast_on_other)
|
||||
@@ -90,6 +91,23 @@ Cursive:RegisterEvent("SPELL_CAST_EVENT", function(success, spellId, castType, t
|
||||
end);
|
||||
```
|
||||
|
||||
### SPELL_BEGIN_CAST_EVENT
|
||||
Event you can register in game to get updates when the clien is about to attempt casting a spell. At this stage the spell is ready and has a valid target, but the spell cast might still be rejected based on line of sight or other factors.
|
||||
|
||||
The event is `SPELL_BEGIN_CAST_EVENT` and has 2 parameters:
|
||||
1. int spellId
|
||||
2. string targetGuid - guid string like "0xF5300000000000A5"
|
||||
|
||||
targetGuid will be “0x0000000000000000” if the spell requires no target
|
||||
|
||||
Example (uses ace RegisterEvent):
|
||||
```
|
||||
Cursive:RegisterEvent("SPELL_BEING_CAST_EVENT", function(spellId, targetGuid)
|
||||
print(spellId)
|
||||
print(targetGuid)
|
||||
end);
|
||||
```
|
||||
|
||||
### SPELL_DAMAGE_EVENT_SELF and SPELL_DAMAGE_EVENT_OTHER
|
||||
New events you can register in game to get updates whenever spell damage occurs. SPELL_DAMAGE_EVENT_SELF will only trigger for damage you deal, while SPELL_DAMAGE_EVENT_OTHER will only trigger for damage dealt by others.
|
||||
|
||||
|
||||
@@ -1443,6 +1443,8 @@ namespace game {
|
||||
|
||||
AURA_CAST_ON_SELF = 560,
|
||||
AURA_CAST_ON_OTHER = 561,
|
||||
|
||||
SPELL_BEGIN_CAST_EVENT = 562,
|
||||
};
|
||||
|
||||
enum TypeMask {
|
||||
|
||||
@@ -1332,6 +1332,9 @@ namespace Nampower {
|
||||
char SPELL_DAMAGE_EVENT_OTHER[] = "SPELL_DAMAGE_EVENT_OTHER";
|
||||
addCustomEvent(game::SPELL_DAMAGE_EVENT_OTHER, SPELL_DAMAGE_EVENT_OTHER);
|
||||
|
||||
char SPELL_BEGIN_CAST_EVENT[] = "SPELL_BEGIN_CAST_EVENT";
|
||||
addCustomEvent(game::SPELL_BEGIN_CAST_EVENT, SPELL_BEGIN_CAST_EVENT);
|
||||
|
||||
char DEBUFF_ADDED_SELF[] = "DEBUFF_ADDED_SELF";
|
||||
addCustomEvent(game::DEBUFF_ADDED_SELF, DEBUFF_ADDED_SELF);
|
||||
|
||||
|
||||
@@ -107,6 +107,21 @@ namespace Nampower {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TriggerSpellBeginCastEvent(uint32_t spellId, std::uint64_t guid) {
|
||||
char format[] = "%d%s";
|
||||
char *guidStr = new char[21]; // 2 for 0x prefix, 18 for the number, and 1 for '\0'
|
||||
std::snprintf(guidStr, 21, "0x%016llX", static_cast<unsigned long long>(guid));
|
||||
|
||||
((int (__cdecl *)(int, char *, uint32_t, char *)) Offsets::SignalEventParam)(
|
||||
game::SPELL_BEGIN_CAST_EVENT, // SPELL_BEGIN_CAST_EVENT event we are adding
|
||||
format,
|
||||
spellId,
|
||||
guidStr);
|
||||
|
||||
delete[] guidStr;
|
||||
}
|
||||
|
||||
bool Spell_C_TargetSpellHook(hadesmem::PatchDetourBase *detour,
|
||||
uint32_t *player,
|
||||
uint32_t *spellId,
|
||||
@@ -236,6 +251,9 @@ namespace Nampower {
|
||||
}
|
||||
|
||||
gLastCastData.startTimeMs = currentTime;
|
||||
|
||||
|
||||
TriggerSpellBeginCastEvent(cast->spellId, cast->unitTarget);
|
||||
}
|
||||
|
||||
void CastQueuedNonGcdSpell() {
|
||||
@@ -1073,6 +1091,7 @@ namespace Nampower {
|
||||
}
|
||||
|
||||
void SendCastHook(hadesmem::PatchDetourBase *detour, game::SpellCast *cast, char unk) {
|
||||
|
||||
auto const sendCast = detour->GetTrampolineT<SendCastT>();
|
||||
sendCast(cast, unk);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user