QQfoolsorellina Posted November 20, 2011 Posted November 20, 2011 (edited) Hi~ I tried to add a custom event OnPCStatCalcEvent to run item script in npc src/map/script.c "OnPCStatCalcEvent",//StatCalcEvent_name src/map/script.h const char *StatCalcEvent_name; src/map/npc.c {"StatCalcEvent",script_config.StatCalcEvent_name}, src/map/npc.h NPCE_PCStatCalc, src/map/status.c + npc_script_event(sd,NPCE_PCStatCalc); + if (!calculating) + return 1; // ----- STATS CALCULATION ----- and a script command BUILDIN_FUNC(CalcCharStat) { TBL_PC *sd; if( script_hasdata(st,2) ) sd=map_id2sd(script_getnum(st,2)); // <Account ID> else sd=script_rid2sd(st); // Attached player if(sd==NULL){ script_pushint(st,-1); return 0; } status_calc_pc(sd,0); return 0; } BUILDIN_DEF(CalcCharStat,"?"), my test script morocc,141,101,4 script eventtset 112,{ set cstate,!cstate; dispbottom "the [cstate] value now is:"+cstate; CalcCharStat; close; OnPCStatCalcEvent: if(cstate){ bonus3 bAutoSpell,48,5,1000; bonus bStr,100; } end; } When cstate=1 the bAutoSpell working as intended but the bStr not work immediately ,Only when re-login character or take off/on equipment , Character's status will be updated My problem is how to update Character's status immediately whithout re-logining or taking off/on equipment ? Edited November 20, 2011 by QQfoolsorellina Quote
GodLesZ Posted November 21, 2011 Posted November 21, 2011 My problem is how to update Character's status immediately whithout re-logining or taking off/on equipment ? Maybe try a atCommand("@refresh"); to refresh the client display. I don't know if it isen't just displayed or need a complete re-calculation. Quote
QQfoolsorellina Posted November 21, 2011 Author Posted November 21, 2011 (edited) My problem is how to update Character's status immediately whithout re-logining or taking off/on equipment ? Maybe try a atCommand("@refresh"); to refresh the client display. I don't know if it isen't just displayed or need a complete re-calculation. Thank you for support. I try add @refresh but status not update.. i think as you say it needs re-calculation morocc,141,101,4 script eventtset 112,{ set cstate,!cstate; dispbottom "the [cstate] value now is:"+cstate; CalcCharStat; close; OnPCStatCalcEvent: if(cstate){ bonus3 bAutoSpell,48,5,1000; bonus bStr,100; atCommand("@refresh"); //add this but still not working as intended } end; } Edited November 21, 2011 by QQfoolsorellina Quote
QQfoolsorellina Posted November 22, 2011 Author Posted November 22, 2011 I dont know how to re-calculation still need help Quote
alopex Posted November 23, 2011 Posted November 23, 2011 Npc Event is slower than status_calc_pc. Quote
dreamunreal Posted November 29, 2011 Posted November 29, 2011 dump. still need help. someone help us? Quote
AnnieRuru Posted October 17, 2012 Posted October 17, 2012 damn ... I found some very interesting topic OnPCStatCalcEvent.patch - script kjfhsdfkjhsd -1,{ OnPCStatCalcEvent: if ( strcharinfo(3) == "prontera" ) // permanently increase 100 str as long as staying in prontera bonus bstr, 100; if ( strcharinfo(0) == "Annieruru" ) // permanently increase 200 agi if the player name Annieruru (me xD) bonus bagi, 200; end; } Quote
QQfoolsorellina Posted October 17, 2012 Author Posted October 17, 2012 damn ... I found some very interesting topic OnPCStatCalcEvent.patch - script kjfhsdfkjhsd -1,{ OnPCStatCalcEvent: if ( strcharinfo(3) == "prontera" ) // permanently increase 100 str as long as staying in prontera bonus bstr, 100; if ( strcharinfo(0) == "Annieruru" ) // permanently increase 200 agi if the player name Annieruru (me xD) bonus bagi, 200; end; } I find the problem is caused by npc_script_event(); when I replace with run_script() , it work as my intended Quote
AnnieRuru Posted October 17, 2012 Posted October 17, 2012 (edited) run_script() as OnPCStatCalcEvent as npc name ? o.O this sounds like this label no able to run more than twice test ... - script kjfhsdfkjhsd -1,{ OnPCStatCalcEvent: bonus bstr, 10; end; } - script kjhdfkjsdfh -1,{ OnPCStatCalcEvent: bonus bagi, 10; end; } - script fjfkjsdfskdfj -1,{ OnPCStatCalcEvent: bonus bvit, 10; end; } can't reproduce error o.o well watever if it works just fine Edited October 17, 2012 by AnnieRuru 2 Quote
kenzffr Posted April 19, 2013 Posted April 19, 2013 After I patched this, do I need to restart the server or just @reloadscript to make it work. Quote
Lil Troll Posted September 10, 2013 Posted September 10, 2013 (edited) Atlast ive been looking for this for thousand of years! I finally found one!(Googled for this one many many time but still got no luck untill now!) Thanks alot to anie and @topic starter. Edited September 10, 2013 by Lil Troll Quote
Question
QQfoolsorellina
Hi~
I tried to add a custom event OnPCStatCalcEvent to run item script
in npc
src/map/script.c
src/map/script.h
src/map/npc.c
src/map/npc.h
src/map/status.c
and a script command
my test script
When cstate=1 the bAutoSpell working as intended
but the bStr not work immediately ,Only when re-login character
or take off/on equipment , Character's status will be updated
My problem is how to update Character's status immediately whithout
re-logining or taking off/on equipment ?
Edited by QQfoolsorellina12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.