diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-07-31 05:37:40 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-07-31 05:37:40 +0000 |
commit | 51680d33aa582128f94a6091fba2e203ebba8faa (patch) | |
tree | e4e3ac63e0cf1b77468f9d593fcc8cc51638cb17 /src/map/script.c | |
parent | b0931e719ce6db2f887e752b1cf55424857a9a1f (diff) | |
download | hercules-51680d33aa582128f94a6091fba2e203ebba8faa.tar.gz hercules-51680d33aa582128f94a6091fba2e203ebba8faa.tar.bz2 hercules-51680d33aa582128f94a6091fba2e203ebba8faa.tar.xz hercules-51680d33aa582128f94a6091fba2e203ebba8faa.zip |
Removed the mob controller system, now a customization (see topic:194375).
The system consists of
* script command to spawn a controlled mob
* script commands to attach npcs to such mobs and manipulate their AI
* a page of documentation for these commands
* callbacks at various source code locations that invoke the attached npcs
* two npc examples
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13021 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 222 |
1 files changed, 0 insertions, 222 deletions
diff --git a/src/map/script.c b/src/map/script.c index 705015c47..c9839a952 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12514,221 +12514,6 @@ BUILDIN_FUNC(pcstopfollow) // [zBuffer] List of mob control commands ---> //## TODO always return if the request/whatever was successfull [FlavioJS] -BUILDIN_FUNC(mobspawn) -{ - int class_,x,y,id; - const char *str,*map; - - // Who? - str =script_getstr(st,2); - // What? - class_ =script_getnum(st,3); - // Where? - map =script_getstr(st,4); - x =script_getnum(st,5); - y =script_getnum(st,6); - - id = mob_once_spawn(map_id2sd(st->rid),map_mapname2mapid(map),x,y,str,class_,1,""); - script_pushint(st,id); - - return 0; -} - -BUILDIN_FUNC(mobremove) -{ - int id; - struct block_list *bl = NULL; - id = script_getnum(st,2); - - bl = map_id2bl(id); - if (bl && bl->type == BL_MOB) - unit_free(bl,0); - - return 0; -} - -BUILDIN_FUNC(getmobdata) -{ - int num, id; - char *name; - struct mob_data *md = NULL; - TBL_PC *sd = st->rid?map_id2sd(st->rid):NULL; - id = script_getnum(st,2); - - if(!(md = (struct mob_data *)map_id2bl(id)) || md->bl.type != BL_MOB || !data_isreference(script_getdata(st,3)) ){ - ShowWarning("buildin_getmobdata: Error in argument!\n"); - return -1; - } - - num=st->stack->stack_data[st->start+3].u.num; - name=(char *)(str_buf+str_data[num&0x00ffffff].str); - setd_sub(st,sd,name,0,(void *)(int)md->class_,script_getref(st,3)); - setd_sub(st,sd,name,1,(void *)(int)md->level,script_getref(st,3)); - setd_sub(st,sd,name,2,(void *)(int)md->status.hp,script_getref(st,3)); - setd_sub(st,sd,name,3,(void *)(int)md->status.max_hp,script_getref(st,3)); - setd_sub(st,sd,name,4,(void *)(int)md->master_id,script_getref(st,3)); - setd_sub(st,sd,name,5,(void *)(int)md->bl.m,script_getref(st,3)); - setd_sub(st,sd,name,6,(void *)(int)md->bl.x,script_getref(st,3)); - setd_sub(st,sd,name,7,(void *)(int)md->bl.y,script_getref(st,3)); - setd_sub(st,sd,name,8,(void *)(int)md->status.speed,script_getref(st,3)); - setd_sub(st,sd,name,9,(void *)(int)md->status.mode,script_getref(st,3)); - setd_sub(st,sd,name,10,(void *)(int)md->special_state.ai,script_getref(st,3)); - setd_sub(st,sd,name,11,(void *)(int)md->sc.option,script_getref(st,3)); - setd_sub(st,sd,name,12,(void *)(int)md->vd->sex,script_getref(st,3)); - setd_sub(st,sd,name,13,(void *)(int)md->vd->class_,script_getref(st,3)); - setd_sub(st,sd,name,14,(void *)(int)md->vd->hair_style,script_getref(st,3)); - setd_sub(st,sd,name,15,(void *)(int)md->vd->hair_color,script_getref(st,3)); - setd_sub(st,sd,name,16,(void *)(int)md->vd->head_bottom,script_getref(st,3)); - setd_sub(st,sd,name,17,(void *)(int)md->vd->head_mid,script_getref(st,3)); - setd_sub(st,sd,name,18,(void *)(int)md->vd->head_top,script_getref(st,3)); - setd_sub(st,sd,name,19,(void *)(int)md->vd->cloth_color,script_getref(st,3)); - setd_sub(st,sd,name,20,(void *)(int)md->vd->shield,script_getref(st,3)); - setd_sub(st,sd,name,21,(void *)(int)md->vd->weapon,script_getref(st,3)); - setd_sub(st,sd,name,22,(void *)(int)md->vd->shield,script_getref(st,3)); - setd_sub(st,sd,name,23,(void *)(int)md->ud.dir,script_getref(st,3)); - setd_sub(st,sd,name,24,(void *)(int)md->state.killer,script_getref(st,3)); - setd_sub(st,sd,name,25,(void *)(int)md->callback_flag,script_getref(st,3)); - setd_sub(st,sd,name,26,(void *)(int)md->state.no_random_walk, script_getref(st,3)); - return 0; -} - -/// Changes the data of a mob -/// -/// setmobdata <mob unit id>,<type>,<value>; -BUILDIN_FUNC(setmobdata) -{ - struct block_list* mob_bl; - - mob_bl = map_id2bl(script_getnum(st,2)); - - if( mob_bl != NULL && mob_bl->type == BL_MOB ) - { - TBL_MOB* md = (TBL_MOB*)mob_bl; - int type; - int value; - - type = script_getnum(st,3); - value = script_getnum(st,4); - - switch( type ) - { - case 0: md->class_ = (short)value; break; - case 1: md->level = (unsigned short)value; break; - case 2: md->status.hp = (unsigned int)value; break; - case 3: md->status.max_hp = (unsigned int)value; break; - case 4: md->master_id = value; break; - case 5: md->bl.m = (short)value; break; - case 6: md->bl.x = (short)value; break; - case 7: md->bl.y = (short)value; break; - case 8: md->status.speed = (unsigned short)value; break; - case 9: md->status.mode = (unsigned short)value; break; - case 10: md->special_state.ai = (unsigned int)value; break; - case 11: md->sc.option = (unsigned short)value; break; - case 12: md->vd->sex = (char)value; break; - case 13: md->vd->class_ = (unsigned short)value; break; - case 14: md->vd->hair_style = (unsigned short)value; break; - case 15: md->vd->hair_color = (unsigned short)value; break; - case 16: md->vd->head_bottom = (unsigned short)value; break; - case 17: md->vd->head_mid = (unsigned short)value; break; - case 18: md->vd->head_top = (unsigned short)value; break; - case 19: md->vd->cloth_color = (unsigned short)value; break; - case 20: md->vd->shield = (unsigned short)value; break; - case 21: md->vd->weapon = (unsigned short)value; break; - case 22: md->vd->shield = (unsigned short)value; break; - case 23: md->ud.dir = (unsigned char)value; break; - case 24: md->state.killer = value > 0 ? 1 : 0; break; - case 25: md->callback_flag = (short)value; break; - case 26: md->state.no_random_walk = value > 0 ? 1 : 0; break; - default: - ShowError("script:setmobdata: unknown data identifier %d\n", type); - return 1; - } - } - - return 0; -} - -/// Makes the mob assist the target unit as a slave -/// -/// mobassist <mob unit id>,"<player name>"; -/// mobassist <mob unit id>,<target id>; -BUILDIN_FUNC(mobassist) -{ - struct block_list* mob_bl; - - // get mob - mob_bl = map_id2bl(script_getnum(st,2)); - if( mob_bl != NULL && mob_bl->type == BL_MOB ) - { - TBL_MOB* md = (TBL_MOB*)mob_bl; - struct block_list* target_bl = NULL; - struct script_data* data; - - // get target - data = script_getdata(st, 3); - get_val(st, data); - if( data_isstring(data) ) - { - TBL_PC* sd = map_nick2sd(conv_str(st, data)); - if( sd != NULL ) - target_bl = &sd->bl; - } - if( target_bl == NULL ) - target_bl = map_id2bl(conv_num(st, data)); - - // set mob as slave - if( target_bl != NULL ) - { - struct unit_data* ud; - - md->master_id = target_bl->id; - md->state.killer = 1; - mob_convertslave(md); - ud = unit_bl2ud(mob_bl); - if( ud != NULL ) - { - if( ud->target != 0 ) - md->target_id = ud->target; - else if( ud->skilltarget != 0 ) - md->target_id = ud->skilltarget; - if( md->target_id != 0 ) - unit_walktobl(&md->bl, map_id2bl(md->target_id), 65025, 2); - } - } - } - - return 0; -} - -/// Attaches the current npc or the target npc to the mob unit -/// -/// mobattach <mob unit id>{,"<npc name>"}; -BUILDIN_FUNC(mobattach) -{ - struct block_list* mob_bl; - - mob_bl = map_id2bl(script_getnum(st,2)); - if( mob_bl != NULL && mob_bl->type == BL_MOB ) - { - TBL_MOB* md = (TBL_MOB*)mob_bl; - TBL_NPC* nd = NULL; - - if( script_hasdata(st,3) ) - nd = npc_name2id(script_getstr(st, 3)); - else - { - struct block_list* npc_bl = map_id2bl(st->oid); - if( npc_bl != NULL && npc_bl->type == BL_NPC ) - nd = (TBL_NPC*)npc_bl; - } - - if( nd != NULL ) - md->nd = nd; - } - - return 0; -} - /// Makes the unit walk to target position or map /// Returns if it was successfull /// @@ -12844,7 +12629,6 @@ BUILDIN_FUNC(unitattack) script_pushint(st, 1); return 0; case BL_MOB: - ((TBL_MOB *)unit_bl)->state.killer = 1; ((TBL_MOB *)unit_bl)->target_id = target_bl->id; break; case BL_PET: @@ -13636,12 +13420,6 @@ struct script_function buildin_func[] = { BUILDIN_DEF(pcblockmove,"ii"), // <--- [zBuffer] List of player cont commands // [zBuffer] List of mob control commands ---> - BUILDIN_DEF(mobspawn,"*"), - BUILDIN_DEF(mobremove,"i"), - BUILDIN_DEF(getmobdata,"i*"), - BUILDIN_DEF(setmobdata,"iii"), - BUILDIN_DEF(mobassist,"i?"), - BUILDIN_DEF(mobattach,"i?"), BUILDIN_DEF(unitwalk,"ii?"), BUILDIN_DEF(unitkill,"i"), BUILDIN_DEF(unitwarp,"isii"), |