Jump to content
  • 0
Sign in to follow this  
mrlongshen

@autopots

Question

Request an autopot for auto heal when player have hp < then 30.

it will @autopot itemid, the item must have on their inventory, so it can be use to autopot.

Is that possible to be a plugin ?

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Can anyone convert this? Thanks in advance :)

 

goddameit autopots: @autopots_3.patch

 

 

Index: src/map/atcommand.c===================================================================--- src/map/atcommand.c	(revision 17132)+++ src/map/atcommand.c	(working copy)@@ -8533,6 +8533,105 @@ 	return; } +//+void autoatpots_clean(struct map_session_data *sd)+{+	if( sd )+	{+		sd->sc.option &= ~OPTION_AUTOPOTS;+		sd->autopots.hp_nameid = 0;+		sd->autopots.hp_rate = 0;+		sd->autopots.sp_nameid = 0;+		sd->autopots.sp_rate = 0;+		clif_changeoption(&sd->bl);+	}+	return;+}+int autoatpots_timer(int tid, unsigned int tick, int id, intptr_t data)+{+	struct map_session_data *sd=NULL;+	struct item_data* item = NULL;+	int index;+	sd=map_id2sd(id);+	if( sd == NULL )+		return 0;+	if(sd->sc.option & OPTION_AUTOPOTS)+	{+		int hp_rate = sd->autopots.hp_rate;+		int sp_rate = sd->autopots.sp_rate;+		int hp_nameid = sd->autopots.hp_nameid;+		int sp_nameid = sd->autopots.sp_nameid;+		if( ( !sp_rate && !hp_rate ) || pc_isdead(sd) )+		{+			clif_displaymessage(sd->fd, "Auto-pots : OFF_");+			autoatpots_clean(sd);+			return 0;+		}+		if( ( sd->battle_status.hp*100/sd->battle_status.max_hp ) < hp_rate && hp_nameid && hp_rate )+		{+			ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == hp_nameid);+			if( sd->status.inventory[index].nameid == hp_nameid )+				pc_useitem(sd,index);+		}+		if( ( sd->battle_status.sp*100/sd->battle_status.max_sp ) < sp_rate && sp_nameid && sp_rate )+		{+			ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == sp_nameid);+			if( sd->status.inventory[index].nameid == sp_nameid )+				pc_useitem(sd,index);+		}+		add_timer(gettick()+500,autoatpots_timer,sd->bl.id,0);+	}+	return 0;+}+ACMD_FUNC(autopots)+{+	int hp_rate=0, hp_nameid=0, sp_rate=0, sp_nameid=0, type=0;+	nullpo_retr(-1, sd);++	if (!message || !*message || +		sscanf(message, "%d %d %d %d %d", &type, &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) < 5 ||+		( type <= 0 || type > 1 ) ||+		( hp_rate < 0 || hp_rate > 99 ) ||+		( sp_rate < 0 || sp_rate > 99 ) )+	{+		clif_displaymessage(fd, "@autopots <type> <hp_rate> <hp_item id> <sp_rate> <sp_item id>");+		clif_displaymessage(fd, "Auto-pots : OFF");+		autoatpots_clean(sd);+		return 0;+	}++	if (sd->sc.option & OPTION_AUTOPOTS)+	{+		autoatpots_clean(sd);+	}+	if( hp_rate == 0 ) hp_nameid = 0;+	if( sp_rate == 0 ) sp_nameid = 0;+	if( hp_nameid == 0 ) hp_rate = 0;+	if( sp_nameid == 0 ) sp_rate = 0;+	if( itemdb_exists(hp_nameid) == NULL && hp_nameid )+	{+		hp_nameid = 0;+		hp_rate = 0;+		clif_displaymessage(fd, "Auto-pots : Invalid item for HP");+	}+	if( itemdb_exists(sp_nameid) == NULL && sp_nameid )+	{+		sp_nameid = 0;+		sp_rate = 0;+		clif_displaymessage(fd, "Auto-pots : Invalid item for SP");+	}+	clif_displaymessage(fd, "Auto-pots : ON");+	sd->sc.option |= OPTION_AUTOPOTS;+	sd->autopots.hp_nameid = hp_nameid;+	sd->autopots.hp_rate = hp_rate;+	sd->autopots.sp_nameid = sp_nameid;+	sd->autopots.sp_rate = sp_rate;+	add_timer(gettick()+200,autoatpots_timer,sd->bl.id,0);++	clif_changeoption(&sd->bl);+	return 0;+}+ /*==========================================  * @commands Lists available @ commands to you  *------------------------------------------*/@@ -8828,6 +8927,8 @@ 	 * Command reference list, place the base of your commands here 	 **/ 	AtCommandInfo atcommand_base[] = {+		ACMD_DEF(autopots),+		// 		ACMD_DEF2("warp", mapmove), 		ACMD_DEF(where), 		ACMD_DEF(jumpto),Index: src/map/pc.h===================================================================--- src/map/pc.h	(revision 17132)+++ src/map/pc.h	(working copy)@@ -87,6 +87,10 @@ 	unsigned short pos; }; +struct autopots {+	int hp_rate, sp_rate, hp_nameid, sp_nameid;+};+ struct map_session_data { 	struct block_list bl; 	struct unit_data ud;@@ -184,6 +188,8 @@ 	unsigned int chatID; 	time_t idletime; +	struct autopots autopots;+ 	struct{ 		int npc_id; 		unsigned int timeout;Index: src/map/status.h===================================================================--- src/map/status.h	(revision 17132)+++ src/map/status.h	(working copy)@@ -1489,6 +1489,7 @@ 	// compound constants 	OPTION_DRAGON    = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5, 	OPTION_MASK      = ~OPTION_INVISIBLE,+	OPTION_AUTOPOTS     = 0x40000000, };  //Defines for the manner system [Skotlex]

 

 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.