Hello, fellow rAtheners, I'm trying to create a new bonus based on AddEff, but which relies on prng/prd instead of uniform chance. I followed the guide on rathena/wiki/Adding-New-Bonuses. The idea is using prd to lessen lucky/unlucky streaks. What I'm trying to achieve is basically this: On every hit: if (proc) {reset chance to initial rate} else {increase rate by C}
What I got so far:
1. SP_ADDEFF_PRNG added to map.h
2. On pc.h, I added (copied from addeff):
struct s_addeffect_prng {
enum sc_type sc; /// SC type/effect
int rate, C; /// Rate (rate should increase by C everytime a proc fails)
short arrow_rate; /// Arrow rate
unsigned char flag; /// Flag
unsigned int duration; /// Duration the effect applied
};
3. status.c, I added sd->addeff_prng.clear(); to the list of sd->addeff.clear(), sd->xyz.clear() etc.
4. pc.c, I copied the original AddEff case and put an extra 0 in the arguments.
case SP_ADDEFF_PRNG: // bonus2 bAddEff_Prng,eff,n;
PC_BONUS_CHK_SC(type2,SP_ADDEFF_PRNG);
pc_bonus_addeff_prng(sd->addeff_prng, (sc_type)type2, sd->state.lr_flag != 2 ? val : 0, sd->state.lr_flag == 2 ? val : 0, 0, 0, 0);
break;
5. scripts_constants.h, I added export_constant2("bAddEffPrng", SP_ADDEFF_PRNG); to the parameters list.
6. Finally, again in pc.c, I cloned the AddEff function, then modified it a bit (in bold). I tried some different stuff, no luck:
The code did compile, but did not produce the intended results. I altered the savage baby card to use the bonus, but it never stunned/froze any monsters at all. I tried adding a message on the added if/else block to check if it was working, but instead of working on hits, it sent the messages when equipping the weapon (and only sent messages on successful procs, never on fails). I also tried looking at battle.c, but couldn't find any 'roll chance for status' sort of stuff there.
What am I doing wrong? Any help would be appreciated.