Jump to content
  • 0

how to prevent item consumption when status is active


Jhedzkie

Question


  • Group:  Members
  • Topic Count:  42
  • Topics Per Day:  0.01
  • Content Count:  297
  • Reputation:   15
  • Joined:  11/17/11
  • Last Seen:  

sorry for the title if it's a bit confusing, i myself could not come up with a better title, and if i have mistakenly put this thread on the wrong forum,

my apologies and i would be thankful to whoever would put this thread onto the proper forum.

anyways, here's my case.

i have a custom item used to invoke a certain SC_CUSTOM_STATUS that i made.

i have used a the item "Field Manual" as my basis on making my custom item.

25000,My_Item,My Item,2,2,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ sc_start SC_CUSTOM_STATUS,1,0; },{},{}

and viola. i had my custom status ready to go,

now, the problem is, even if the status is still active, when i use one more of my custom item, it is being consumed.

unlike the field manual that when the SC_EXPBOOST is active, when you use another field manual, it will not be consumed.

how can i prevent my item from being consumed when my custom status is active?

how can i make my item work just like how the field manual does?

your feedback would really be a great help.

thanks in advanced.

post-376-0-06578900-1321654202_thumb.png

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   167
  • Joined:  11/10/11
  • Last Seen:  

Go into map/pc.c and find:

case 14592: // JOB_Battle_Manual
    if( sd->sc.data[sC_JEXPBOOST] )
         return 0;
    break;

Below add:

case 25000:
    if( sd->sc.data[sC_CUSTOM_STATUS] )
         return 0;
    break;

Edit accordingly and recompile afterwards :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  128
  • Reputation:   4
  • Joined:  11/14/11
  • Last Seen:  

25000,My_Item,My Item,2,2,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ if (@last_item_consumed+300 > gettimetick(2)) { dispbottom "You are not allowed to use this"; getitem 25000,1; end; } sc_start SC_CUSTOM_STATUS,1,0;  set @last_item_consumed, gettimetick(2); end;},{},{}

Just adjust the +300 if you want to extend the time in order not to be used by the players while the status is active.

Got this code from Annie's megaphone.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  42
  • Topics Per Day:  0.01
  • Content Count:  297
  • Reputation:   15
  • Joined:  11/17/11
  • Last Seen:  

hmm. i tried it out and it's good. but,

cant it be something like,

{ if(check_if_status_is_active(SC_STATUS_NAME)){//cant use item blah blah blah. } else { sc_start(SC_STATUS_NAME,1,0);}}

it works fairly well with items such as the field manual and bublegum, so im starting too feel like this needs some src edits perhaps?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  128
  • Reputation:   4
  • Joined:  11/14/11
  • Last Seen:  

it would be easy defining it as to this:

example:

1800000 <-- default time

sc_start SC_WINDWALK,1800000,5;

then set the time to what ever you set above..

300 <-- default time

if(@last_item_consumed+300 > gettimetick (2))

regarding src mod. i don't have any idea how to do it. :D

And this thread should be here: http://eathena.net/board/forum/36-source-modification-requests/

Edited by simplynice
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   153
  • Joined:  11/10/11
  • Last Seen:  

That's probably something that should be optimized anyway. It's not a good idea to hard code such information. Your approach is correct Epoque, it's just that this kind of things have been handled the wrong way from the start and there is no other way to solve this.

A better idea is to add new script commands that allows to check for some status changes and behave accordingly. Here's an example (which hasn't been tested though):

BUILDIN_FUNC(getscdata)
{
struct map_session_data *sd = NULL;
int sc_type = script_getnum(st,2);
if(script_hasdata(st,3))
 sd = map_nick2sd(script_getstr(st,3));
else
 sd = script_rid2sd(st);
if(sc_type >= 0 && sc_type < SC_MAX && sd && sd->sc.data[sc_type])
{
 struct status_change_entry *sce = sd->sc.data[sc_type];
 pc_setreg(sd, reference_uid(add_str("@scdata"), 0), sc_type);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 1), sce->timer);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 2), sce->val1);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 3), sce->val2);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 4), sce->val3);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 5), sce->val4);
 script_pushint(st, 1);
 return 0;
}
script_pushint(st, 0);
return 0;
}

In combination with an exp manual, the item script would look like this:

14532,Battle_Manual25,Field Manual 25%,2,,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ if(!getscdata(SC_EXPBOOST)) sc_start SC_EXPBOOST,1800000,25; },{},{}

This approach does not only benefit from being more flexible. It also allows scripts to use the newly created script commands.

You can check other players for status changes, how long the status will remain, etc. It will simply fill the @scdata array with those information.

Or have I missed something and didn't take it into account?

Edited by Shinryo
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   167
  • Joined:  11/10/11
  • Last Seen:  

That's probably something that should be optimized anyway. It's not a good idea to hard code such information. Your approach is correct Epoque, it's just that this kind of things have been handled the wrong way from the start and there is no other way to solve this.

A better idea is to add new script commands that allows to check for some status changes and behave accordingly. Here's an example (which hasn't been tested though):

BUILDIN_FUNC(getscdata)
{
struct map_session_data *sd = NULL;
int sc_type = script_getnum(st,2);
if(script_hasdata(st,3))
 sd = map_nick2sd(script_getstr(st,3));
else
 sd = script_rid2sd(st);
if(sc_type >= 0 && sc_type < SC_MAX && sd && sd->sc.data[sc_type])
{
 struct status_change_entry *sce = sd->sc.data[sc_type];
 pc_setreg(sd, reference_uid(add_str("@scdata"), 0), sc_type);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 1), sce->timer);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 2), sce->val1);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 3), sce->val2);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 4), sce->val3);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 5), sce->val4);
 script_pushint(st, 1);
 return 0;
}
script_pushint(st, 0);
return 0;
}

In combination with an exp manual, the item script would look like this:

14532,Battle_Manual25,Field Manual 25%,2,,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ if(!getscdata(SC_EXPBOOST)) sc_start SC_EXPBOOST,1800000,25; },{},{}

This approach does not only benefit from being more flexible. It also allows scripts to use the newly created script commands.

You can check other players for status changes, how long the status will remain, etc. It will simply fill the @scdata array with those information.

Or have I missed something and didn't take it into account?

Agreed, it's certainly been one of those things eAthena has just kind of stuck together for a long time. In my expansion system that was on sale, I ended up creating a command just like that to accommodate items and scripts easier :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  42
  • Topics Per Day:  0.01
  • Content Count:  297
  • Reputation:   15
  • Joined:  11/17/11
  • Last Seen:  

Go into map/pc.c and find:

case 14592: // JOB_Battle_Manual
 if( sd->sc.data[sC_JEXPBOOST] )
	  return 0;
 break;

Below add:

case 25000:
 if( sd->sc.data[sC_CUSTOM_STATUS] )
	  return 0;
 break;

Edit accordingly and recompile afterwards :)

thanks Epoque for this, it worked out as needed.

That's probably something that should be optimized anyway. It's not a good idea to hard code such information. Your approach is correct Epoque, it's just that this kind of things have been handled the wrong way from the start and there is no other way to solve this.

A better idea is to add new script commands that allows to check for some status changes and behave accordingly. Here's an example (which hasn't been tested though):

BUILDIN_FUNC(getscdata)
{
struct map_session_data *sd = NULL;
int sc_type = script_getnum(st,2);
if(script_hasdata(st,3))
 sd = map_nick2sd(script_getstr(st,3));
else
 sd = script_rid2sd(st);
if(sc_type >= 0 && sc_type < SC_MAX && sd && sd->sc.data[sc_type])
{
 struct status_change_entry *sce = sd->sc.data[sc_type];
 pc_setreg(sd, reference_uid(add_str("@scdata"), 0), sc_type);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 1), sce->timer);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 2), sce->val1);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 3), sce->val2);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 4), sce->val3);
 pc_setreg(sd, reference_uid(add_str("@scdata"), 5), sce->val4);
 script_pushint(st, 1);
 return 0;
}
script_pushint(st, 0);
return 0;
}

In combination with an exp manual, the item script would look like this:

14532,Battle_Manual25,Field Manual 25%,2,,,10,,,,,0xFFFFFFFF,7,2,,,,,,{ if(!getscdata(SC_EXPBOOST)) sc_start SC_EXPBOOST,1800000,25; },{},{}

This approach does not only benefit from being more flexible. It also allows scripts to use the newly created script commands.

You can check other players for status changes, how long the status will remain, etc. It will simply fill the @scdata array with those information.

Or have I missed something and didn't take it into account?

and thanks to you too, Shinryo.

however, when i tried it out, the item invoking the status is still being consumed while the status is still active.

i am not really an src guy, so i cant really figure out what's what with the codes. ;p

but, i do know how to re-compile. :)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   167
  • Joined:  11/10/11
  • Last Seen:  

If you were to try Shinryo's code, you'd need to change the item type to '11' and set the item script to:

{ if( !getscdata(SC_EXPBOOST) ) { sc_start SC_EXPBOOST, 1800000, 25; delitem 14532, 1; } }

  • Upvote 1
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...