summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-03-22 03:34:40 -0300
committershennetsind <ind@henn.et>2013-03-22 03:34:40 -0300
commitc58f741a0f2b807cbeb065c2dbbfe4f86dfb95b2 (patch)
tree28b2d6b5c103334fb86ac2ebc2627c5380296e28 /src/map/script.c
parent77039104c0b66d524714487d7c14adb142b76ba8 (diff)
downloadhercules-c58f741a0f2b807cbeb065c2dbbfe4f86dfb95b2.tar.gz
hercules-c58f741a0f2b807cbeb065c2dbbfe4f86dfb95b2.tar.bz2
hercules-c58f741a0f2b807cbeb065c2dbbfe4f86dfb95b2.tar.xz
hercules-c58f741a0f2b807cbeb065c2dbbfe4f86dfb95b2.zip
Adding itemeffect script command
as per Script Dev Streusel request. Originally 'consumeitem', renamed for we thought the name was misleading (since it didn't consume anything). Merged from rAthena - lemongrass3110 Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index cd5a1a324..4c913651a 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9557,6 +9557,44 @@ static int buildin_announce_sub(struct block_list *bl, va_list ap)
clif_broadcast(bl, mes, len, type, SELF);
return 0;
}
+/* Runs item effect on attached character.
+ * consumeitem <item id>;
+ * consumeitem "<item name>"; */
+BUILDIN_FUNC(itemeffect) {
+ TBL_NPC *nd;
+ TBL_PC *sd;
+ struct script_data *data;
+ struct item_data *item_data;
+
+ nullpo_retr( 1, ( sd = script_rid2sd( st ) ) );
+ nullpo_retr( 1, ( nd = (TBL_NPC *)map_id2bl( sd->npc_id ) ) );
+
+ data = script_getdata( st, 2 );
+ get_val( st, data );
+
+ if( data_isstring( data ) ){
+ const char *name = conv_str( st, data );
+
+ if( ( item_data = itemdb_searchname( name ) ) == NULL ){
+ ShowError( "buildin_itemeffect: Nonexistant item %s requested.\n", name );
+ return 1;
+ }
+ }else if( data_isint( data ) ){
+ int nameid = conv_num( st, data );
+
+ if( ( item_data = itemdb_exists( nameid ) ) == NULL ){
+ ShowError("buildin_itemeffect: Nonexistant item %d requested.\n", nameid );
+ return 1;
+ }
+ }else{
+ ShowError("buildin_itemeffect: invalid data type for argument #1 (%d).", data->type );
+ return 1;
+ }
+
+ run_script( item_data->script, 0, sd->bl.id, nd->bl.id );
+
+ return 0;
+}
BUILDIN_FUNC(mapannounce)
{
@@ -17784,6 +17822,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(cleanmap,"s"),
BUILDIN_DEF2(cleanmap,"cleanarea","siiii"),
BUILDIN_DEF(npcskill,"viii"),
+ BUILDIN_DEF(itemeffect,"v"),
/**
* @commands (script based)
**/