Jump to content
  • 0

about update character's status


Question

Posted (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 by QQfoolsorellina

12 answers to this question

Recommended Posts

Posted

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.

Posted (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 by QQfoolsorellina
Posted

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;
}

Posted

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

Posted (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;
}

post-8685-0-62024800-1350469736_thumb.jpg

can't reproduce error o.o

well watever if it works just fine

Edited by AnnieRuru
  • Upvote 2
Posted (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 by Lil Troll

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...