Jump to content
  • 0

about update character's status


QQfoolsorellina

Question


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

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
Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  1
  • Reputation:   0
  • Joined:  11/23/11
  • Last Seen:  

Npc Event is slower than status_calc_pc.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   8
  • Joined:  11/16/11
  • Last Seen:  

dump. still need help.

someone help us?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  40
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   104
  • Joined:  11/19/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  09/09/12
  • Last Seen:  

After I patched this, do I need to restart the server or just @reloadscript to make it work.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

patch -> (re)compile -> restart server

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  09/09/12
  • Last Seen:  

Thx alot Cydh

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  276
  • Reputation:   24
  • Joined:  07/06/13
  • Last Seen:  

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
Link to comment
Share on other sites

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.

×
×
  • Create New...