• 0
danielpqb

[HELP] Item delay

Question

Hi,

I was trying to create an item group delay. I tried editing itemdb.c and pc.c but didn't have any success.

To be more specific, let me give you an example of what I want:

If I consume a Red Potion, I'd like that the Orange, Yellow, White and the Red Potions get the same delay to use again (let's say 5 seconds). So it won't be possible to use any potion again if I consumed a Red, Orange, Yellow or White Potion in the last 5 seconds.

I hope what I have requested is possible.

In the meantime, thank you for your attention.

Share this post


Link to post
Share on other sites

7 answers to this question

  • 0

I know one way to do that, go to conf\map\battle\items.conf and change  that:

item_use_interval: 5000.

 

It gonna make a delay between using items.

 

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, Juan Meissner said:

I know one way to do that, go to conf\map\battle\items.conf and change  that:

item_use_interval: 5000.

 

It gonna make a delay between using items.

 

This way will create a delay for all items, so I won't be able to use other items like Yggleaf etc.

Nevertheless, I appreciate your comment.

Share this post


Link to post
Share on other sites
  • 0

Yes I was doing this, but if I put 5 seconds delay on each Potion, would be possible to alternate using Red then Orange then Yellow then White Potion. So the character would spam potions anyway.

I was looking for something on pc.c file but I don't know much about the commands.

Share this post


Link to post
Share on other sites
  • 0

at pc.c under pc_useitem you will see the item delay function which is under if( sd->inventory_data[n]->delay > 0 ) { where you need to do is add a variable on sd and that will hold all delays that has been activated..so stack all those add a tick check then clear once the delay duration has lapse...

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, malufett said:

at pc.c under pc_useitem you will see the item delay function which is under if( sd->inventory_data[n]->delay > 0 ) { where you need to do is add a variable on sd and that will hold all delays that has been activated..so stack all those add a tick check then clear once the delay duration has lapse...

Thank you for your help.

Actually I didn't understand what you mean with "add a variable on sd", but after hours of trouble I came to a solution that works:

if( sd->inventory_data[n]->delay > 0 ) {
		ARR_FIND(0, MAX_ITEMDELAYS, i, sd->item_delay[i].nameid == nameid );
		if( nameid == ITEMID_RED_POTION || nameid == ITEMID_YELLOW_POTION || nameid == ITEMID_WHITE_POTION ) {
			sd->item_delay[1].nameid = ITEMID_RED_POTION;
			sd->item_delay[2].nameid = ITEMID_YELLOW_POTION;
			sd->item_delay[3].nameid = ITEMID_WHITE_POTION;
		}
			if( i == MAX_ITEMDELAYS ) /* item not found. try first empty now */
				ARR_FIND(0, MAX_ITEMDELAYS, i, !sd->item_delay[i].nameid );
		if( i < MAX_ITEMDELAYS ) {
			if( sd->item_delay[i].nameid ) {// found
				if( DIFF_TICK(sd->item_delay[i].tick, tick) > 0 ) {
					int e_tick = (int)(DIFF_TICK(sd->item_delay[i].tick, tick)/1000);
//					clif->msgtable_num(sd, MSG_SECONDS_UNTIL_USE, e_tick + 1); // [%d] seconds left until you can use
					return 0; // Delay has not expired yet
				}
			} else {// not yet used item (all slots are initially empty)
				sd->item_delay[i].nameid = nameid;
			}
			if( sd->item_delay[1].nameid == ITEMID_RED_POTION || sd->item_delay[2].nameid == ITEMID_YELLOW_POTION || sd->item_delay[3].nameid == ITEMID_WHITE_POTION ){
				sd->item_delay[1].tick = tick + 5000;
				sd->item_delay[2].tick = tick + 5000;
				sd->item_delay[3].tick = tick + 5000;
				goto limpartudo;
			}
			if (!(nameid == ITEMID_BOARDING_HALTER && pc_hasmount(sd))) {
				sd->item_delay[i].tick = tick + sd->inventory_data[n]->delay;
			}
		} else {// should not happen
			ShowError("pc_useitem: Exceeded item delay array capacity! (nameid=%d, char_id=%d)\n", nameid, sd->status.char_id);
		}
		//clean up used delays so we can give room for more
		limpartudo:
		for(i = 0; i < MAX_ITEMDELAYS; i++) {
			if( DIFF_TICK(sd->item_delay[i].tick, tick) <= 0 ) {
				sd->item_delay[i].tick = 0;
				sd->item_delay[i].nameid = 0;
			}
		}
	}

I wonder if you could help me with a better solution, because my code is an outrage to the community. hahahahahah

I thank you all for the good cooperation!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now