Hello.
I have an idea for yet another Ledge Invincibility Staling mechanic, that sounds simple enough to implement, albeit somewhat laborious, except for a key detail: I would like to add a few variables to the player character structure to keep track of some ledgegrab state.
I have some experience programming at asm-level, but know next to nothing about hacking a live program other than the concept of injecting branches to new code.
As such, I know what I want to do, but I have no idea where to do it, nor I know how hard it actually is to implement.
The most modding I've actually done on Melee is customizing a few characters with Crazy Hand.
The idea is to add ledge staling in 4 levels, which reduces ledge invincibility from full to only a quarter at worst, covering pretty much only the ledgegrab portion.
The staling level increases when the player regrabs the ledge 2, 6 (2+4), and 14 (2+4+8) times respectively, and decreases by touching the ground after ledgegrabbing and staying off the ledge for 15 seconds (900 frames) (effectively reducing the ledgegrab count from 14+ to 14, 6+ to 6, 2+ to 2, and 0+ to 0 otherwise)
As such, it needs to add onto the player character structure two bitflags, one for when the timer has to run and one for when the character has ledgegrabbed and hasn't yet touched ground, and two variables for the timer and (resetable) ledgegrab count.
In a pinch, all of this data could fit in 24 bits of space, perhaps reducing the two bitflags to only one, but a variable has to be added nonetheless.
The problems I have with it are two:
1. I have no idea how to add variables to the player structure.
What I suppose would be needed, if there is no exploitable free space in the already existing structure, and assuming that player character structures are dynamically allocated, is to locate and modify the allocation of the structure to allocate the space needed for the additional variables.
This is trivial enough given the source code, but if other places in the game assume the size of the structure, then those are to be manually modified as well, and if it moves around data that shouldn't be moved, then I have no idea how to recover from that.
2. I don't know where to find the functions I want to inject my code into.
This stems from my inexperience with Melee's structure, so definitely a fault on my part, but a roadblock nonetheless! I know of the
My question thus is as follows:
Is it doable? How hard would it be to add variables for each player? Would another approach work better to achieve the same?
Spoilered below is a more detailed description/half pseudocode of what I would want to achieve.
Thanks for your time if you read all of this.
I have an idea for yet another Ledge Invincibility Staling mechanic, that sounds simple enough to implement, albeit somewhat laborious, except for a key detail: I would like to add a few variables to the player character structure to keep track of some ledgegrab state.
I have some experience programming at asm-level, but know next to nothing about hacking a live program other than the concept of injecting branches to new code.
As such, I know what I want to do, but I have no idea where to do it, nor I know how hard it actually is to implement.
The most modding I've actually done on Melee is customizing a few characters with Crazy Hand.
The idea is to add ledge staling in 4 levels, which reduces ledge invincibility from full to only a quarter at worst, covering pretty much only the ledgegrab portion.
The staling level increases when the player regrabs the ledge 2, 6 (2+4), and 14 (2+4+8) times respectively, and decreases by touching the ground after ledgegrabbing and staying off the ledge for 15 seconds (900 frames) (effectively reducing the ledgegrab count from 14+ to 14, 6+ to 6, 2+ to 2, and 0+ to 0 otherwise)
As such, it needs to add onto the player character structure two bitflags, one for when the timer has to run and one for when the character has ledgegrabbed and hasn't yet touched ground, and two variables for the timer and (resetable) ledgegrab count.
In a pinch, all of this data could fit in 24 bits of space, perhaps reducing the two bitflags to only one, but a variable has to be added nonetheless.
The problems I have with it are two:
1. I have no idea how to add variables to the player structure.
What I suppose would be needed, if there is no exploitable free space in the already existing structure, and assuming that player character structures are dynamically allocated, is to locate and modify the allocation of the structure to allocate the space needed for the additional variables.
This is trivial enough given the source code, but if other places in the game assume the size of the structure, then those are to be manually modified as well, and if it moves around data that shouldn't be moved, then I have no idea how to recover from that.
2. I don't know where to find the functions I want to inject my code into.
This stems from my inexperience with Melee's structure, so definitely a fault on my part, but a roadblock nonetheless! I know of the
My question thus is as follows:
Is it doable? How hard would it be to add variables for each player? Would another approach work better to achieve the same?
Spoilered below is a more detailed description/half pseudocode of what I would want to achieve.
Player Variables to be added:
Optional variables, calculated by functions:
Functions:
Code to be injected:
LGP: A variable set when ledgegrabbing, unset when landing.
LGCnt: A modifiable ledgegrab counter.
LGTmOn = 0-1;
LGTm = 0-900: Two variables for the ledge unstaling timer.
Optional variables, calculated by functions:
LGInvK = the default ledge invincibility duration taken from PlCo.dat.
Ledge staling level: LGStL = 0-3; LGStL = case LGCnt: if <2: 0; if <6: 1; if <14: 2; else: 3
Ledge invincibility: LGInv = LGInvK * (4 - LGStL) / 4
Functions:
"reset timer" = set LGTmOn to 0, LGTm to 0.
"start timer" = set LGTmOn to 1.
"reset ledgegrab count" = Set LGCnt to 0, LGP to 0.
"reduce staling level" = LGCnt = case LGCnt: if <2: 0; if <6: 2; if <14: 6; else: 14
Code to be injected:
somewhere in the player loop: Increase LGTm if LGTmOn is set, if it is >= 900 reduce staling level and set it to 0.
on Spawn/Death (where it is more appropriate): reset ledgegrab count, reset timer.
on LedgeGrab: Increase LGCnt, set LGP, reset timer, set invincibility for LGInv frames.
on Landing (where DJ is restored): check whether LGP is set, unset it and start timer if it is.
Thanks for your time if you read all of this.
Last edited: