From 17d000640dd7ddec80cbfe6031fe6131dec79ff9 Mon Sep 17 00:00:00 2001 From: Euphy Date: Wed, 4 Sep 2013 15:07:26 -0400 Subject: [PATCH] * Added 'breakequip' script command. (tid:86732) * Fixed return value for delequip. (since r17469/8bd0985) * Fixed a bug with Mercenary Rentals. (credits: TTest) Signed-off-by: Euphy --- doc/script_commands.txt | 10 ++++++++++ npc/other/mercenary_rent.txt | 6 +++--- src/map/script.c | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f831f61133..c1fc3fba46 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4610,6 +4610,16 @@ This command will return 1 if an item was deleted and 0 otherwise. --------------------------------------- +*breakequip ; + +This command will break and unequip whatever is currently equipped in the +invoking character's specified equipment slot. For a full list of possible +equipment slots see 'getequipid'. + +This command will return 1 if an item was deleted and 0 otherwise. + +--------------------------------------- + *clearitem; This command will destroy all items the invoking character has in their diff --git a/npc/other/mercenary_rent.txt b/npc/other/mercenary_rent.txt index 19b9079de8..7d5b02fdd1 100644 --- a/npc/other/mercenary_rent.txt +++ b/npc/other/mercenary_rent.txt @@ -22,10 +22,10 @@ setarray .@name$, "Spear", "Sword", "Bow"; setarray .@faith$, "SPEAR_MERC_GUILD", "SWORD_MERC_GUILD", "ARCH_MERC_GUILD"; setarray .@item, 12182, 12172, 12162; - set .@faith_lancer, mercenary_get_faith(getd(.@faith$[.@type])); set .@npc$, strnpcinfo(2); for (set .@size, getarraysize(.@name$); .@i < .@size; set .@i, .@i + 1) if (.@npc$ == .@name$[.@i]) set .@type, .@i; + set .@faith_merc, mercenary_get_faith(getd(.@faith$[.@type])); mes "[Mercenary Manager]"; mes "Welcome to the"; mes .@npc$ + " Mercenary Guild."; @@ -64,7 +64,7 @@ mes "free to come back if your"; mes "needs change. Thank you~"; } - else if(.@FaithCost && .@faith_lancer < .@FaithCost) { + else if(.@FaithCost && .@faith_merc < .@FaithCost) { mes "[Mercenary Manager]"; mes "Oh... Your Loyalty rating"; mes "with the " + .@npc$ + " Mercenary"; @@ -178,7 +178,7 @@ mes "Mercenary. Have you considered"; mes "hiring a lower grade Mercenary?"; } - else if (.@faith_lancer < 500) { + else if (.@faith_merc < 500) { mes "[Mercenary Manager]"; mes "I'm sorry, but your"; mes "Loyalty rating is too"; diff --git a/src/map/script.c b/src/map/script.c index 0d63181b86..1b92f1ef23 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -7798,7 +7798,7 @@ BUILDIN_FUNC(downrefitem) *------------------------------------------*/ BUILDIN_FUNC(delequip) { - int i=-1,num; + int i=-1,num,ret=0; TBL_PC *sd; num = script_getnum(st,2); @@ -7809,12 +7809,37 @@ BUILDIN_FUNC(delequip) if (num > 0 && num <= ARRAYLENGTH(equip)) i=pc_checkequip(sd,equip[num-1]); if(i >= 0) { - int ret; pc_unequipitem(sd,i,3); //recalculate bonus - ret=pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT); - script_pushint(st,ret==0); + ret = !(pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT)); } + script_pushint(st,ret); + return 0; +} + +/*========================================== + * Break the item equipped at pos. + *------------------------------------------*/ +BUILDIN_FUNC(breakequip) +{ + int i=-1,num; + TBL_PC *sd; + + num = script_getnum(st,2); + sd = script_rid2sd(st); + if( sd == NULL ) + return 0; + + if (num > 0 && num <= ARRAYLENGTH(equip)) + i = pc_checkequip(sd,equip[num-1]); + if (i >= 0) { + sd->status.inventory[i].attribute = 1; + pc_unequipitem(sd,i,3); + clif_equiplist(sd); + script_pushint(st,1); + } else + script_pushint(st,0); + return 0; } @@ -18437,6 +18462,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(npcskill,"viii"), BUILDIN_DEF(consumeitem,"v"), BUILDIN_DEF(delequip,"i"), + BUILDIN_DEF(breakequip,"i"), BUILDIN_DEF(sit,"?"), BUILDIN_DEF(stand,"?"), /**