forked from coremaze/Cube-World-Mod-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0954035
commit fb754d6
Showing
5 changed files
with
54 additions
and
36 deletions.
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
Submodule CWSDK
updated
from 41ab83 to bb96f1
41 changes: 8 additions & 33 deletions
41
CubeModLoader/callbacks/creature/cube__Creature__GetArmor.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
41 changes: 41 additions & 0 deletions
41
CubeModLoader/callbacks/creature/cube__Creature__OnPlayerDeath.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
extern "C" void cube__Creature__OnPlayerDeath(cube::Game* game) | ||
{ | ||
cube::Creature* player = game->world->local_creature; | ||
player->entity_data.HP = 0; | ||
|
||
for (uint8_t priority = 0; priority <= 4; priority += 1) { | ||
for (DLL* dll : modDLLs) { | ||
if (dll->mod->OnPlayerDeathPriority == (GenericMod::Priority)priority) { | ||
dll->mod->OnPlayerDeath(game, player); | ||
} | ||
} | ||
} | ||
} | ||
|
||
extern "C" void SoundPacket__ctor(void* a1) | ||
{ | ||
((void (*)(void*))CWOffset(0x80270))(a1); | ||
} | ||
|
||
GETTER_VAR(void*, ASM_cube__Creature__OnPlayerDeath_JMPBACK); | ||
__attribute__((naked)) void ASM_cube__Creature__OnPlayerDeath() { | ||
asm(".intel_syntax \n" | ||
|
||
// Move current cube::Game* to the first argument. | ||
// This does not have to be restored, because rcx is set to a value afterwards anyways | ||
"mov rcx, r13 \n" | ||
"call cube__Creature__OnPlayerDeath \n" | ||
|
||
// Old code | ||
"lea rcx, [rbp+0x0A20] \n" | ||
"call SoundPacket__ctor \n" | ||
DEREF_JMP(ASM_cube__Creature__OnPlayerDeath_JMPBACK) | ||
); | ||
} | ||
|
||
void setup_cube__Creature__OnPlayerDeath() { | ||
WriteFarJMP(CWOffset(0xA8EE7), (void*)&ASM_cube__Creature__OnPlayerDeath); | ||
ASM_cube__Creature__OnPlayerDeath_JMPBACK = CWOffset(0xA8EFA); | ||
} |
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