[HELP] Item delay

danielpqb

New member
Messages
6
Points
0
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.

 
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.

 
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.

 
What abou use this?

Delay: Delay to use item      (int, defaults to 0)

some items in DB use Delay option.

 
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.

 
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...

 
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.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.nameid );
if( i < MAX_ITEMDELAYS ) {
if( sd->item_delay.nameid ) {// found
if( DIFF_TICK(sd->item_delay.tick, tick) > 0 ) {
int e_tick = (int)(DIFF_TICK(sd->item_delay.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.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.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.tick, tick) <= 0 ) {
sd->item_delay.tick = 0;
sd->item_delay.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!

 
Back
Top