[1] | 1 | // Copyright (c) Athena Dev Teams - Licensed under GNU GPL |
---|
| 2 | // For more information, see LICENCE in the main folder |
---|
| 3 | |
---|
| 4 | #ifndef _NPC_H_ |
---|
| 5 | #define _NPC_H_ |
---|
| 6 | |
---|
| 7 | #include "map.h" // struct block_list |
---|
| 8 | #include "status.h" // struct status_change |
---|
| 9 | #include "unit.h" // struct unit_data |
---|
| 10 | struct block_list; |
---|
| 11 | struct npc_data; |
---|
| 12 | struct view_data; |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | struct npc_timerevent_list { |
---|
| 16 | int timer,pos; |
---|
| 17 | }; |
---|
| 18 | struct npc_label_list { |
---|
| 19 | char name[NAME_LENGTH]; |
---|
| 20 | int pos; |
---|
| 21 | }; |
---|
| 22 | struct npc_item_list { |
---|
| 23 | unsigned int nameid,value; |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | struct npc_data { |
---|
| 27 | struct block_list bl; |
---|
| 28 | struct unit_data ud; //Because they need to be able to move.... |
---|
| 29 | struct view_data *vd; |
---|
| 30 | struct status_change sc; //They can't have status changes, but.. they want the visual opt values. |
---|
| 31 | struct npc_data *master_nd; |
---|
| 32 | short class_; |
---|
| 33 | short speed; |
---|
| 34 | char name[NAME_LENGTH+1];// display name |
---|
| 35 | char exname[NAME_LENGTH+1];// unique npc name |
---|
| 36 | int chat_id; |
---|
| 37 | unsigned int next_walktime; |
---|
| 38 | |
---|
| 39 | unsigned size : 2; |
---|
| 40 | |
---|
| 41 | void* chatdb; // pointer to a npc_parse struct (see npc_chat.c) |
---|
| 42 | enum npc_subtype subtype; |
---|
| 43 | union { |
---|
| 44 | struct { |
---|
| 45 | struct script_code *script; |
---|
| 46 | short xs,ys; // OnTouch area radius |
---|
| 47 | int guild_id; |
---|
| 48 | int timer,timerid,timeramount,rid; |
---|
| 49 | unsigned int timertick; |
---|
| 50 | struct npc_timerevent_list *timer_event; |
---|
| 51 | int label_list_num; |
---|
| 52 | struct npc_label_list *label_list; |
---|
| 53 | int src_id; |
---|
| 54 | } scr; |
---|
| 55 | struct { |
---|
| 56 | struct npc_item_list* shop_item; |
---|
| 57 | int count; |
---|
| 58 | } shop; |
---|
| 59 | struct { |
---|
| 60 | short xs,ys; // OnTouch area radius |
---|
| 61 | short x,y; // destination coords |
---|
| 62 | unsigned short mapindex; // destination map |
---|
| 63 | } warp; |
---|
| 64 | } u; |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | #define START_NPC_NUM 110000000 |
---|
| 70 | |
---|
| 71 | #define WARP_CLASS 45 |
---|
| 72 | #define WARP_DEBUG_CLASS 722 |
---|
| 73 | #define FLAG_CLASS 722 |
---|
| 74 | #define INVISIBLE_CLASS 32767 |
---|
| 75 | |
---|
| 76 | #define MAX_NPC_CLASS 1000 |
---|
| 77 | //Checks if a given id is a valid npc id. [Skotlex] |
---|
| 78 | //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) |
---|
| 79 | #define npcdb_checkid(id) ((id >= 46 && id <= 125) || id == 139 || (id >= 400 && id <= MAX_NPC_CLASS) || id == INVISIBLE_CLASS) |
---|
| 80 | |
---|
| 81 | #ifdef PCRE_SUPPORT |
---|
| 82 | void npc_chat_finalize(struct npc_data* nd); |
---|
| 83 | int mob_chat_sub(struct block_list* bl, va_list ap); |
---|
| 84 | #endif |
---|
| 85 | |
---|
| 86 | //Script NPC events. |
---|
| 87 | enum npce_event { |
---|
| 88 | NPCE_LOGIN, |
---|
| 89 | NPCE_LOGOUT, |
---|
| 90 | NPCE_LOADMAP, |
---|
| 91 | NPCE_BASELVUP, |
---|
| 92 | NPCE_JOBLVUP, |
---|
| 93 | NPCE_DIE, |
---|
| 94 | NPCE_KILLPC, |
---|
| 95 | NPCE_KILLNPC, |
---|
| 96 | NPCE_MAX |
---|
| 97 | }; |
---|
| 98 | struct view_data* npc_get_viewdata(int class_); |
---|
| 99 | int npc_chat_sub(struct block_list* bl, va_list ap); |
---|
| 100 | int npc_event_dequeue(struct map_session_data* sd); |
---|
| 101 | int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill); |
---|
| 102 | int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y); |
---|
| 103 | int npc_touch_areanpc2(struct mob_data *md); // [Skotlex] |
---|
| 104 | int npc_check_areanpc(int flag, int m, int x, int y, int range); |
---|
| 105 | int npc_click(struct map_session_data* sd, struct npc_data* nd); |
---|
| 106 | int npc_scriptcont(struct map_session_data* sd, int id); |
---|
| 107 | struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl); |
---|
| 108 | int npc_buysellsel(struct map_session_data* sd, int id, int type); |
---|
| 109 | int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list); |
---|
| 110 | int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list); |
---|
| 111 | void npc_parse_mob2(struct spawn_data* mob); |
---|
| 112 | struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); |
---|
| 113 | int npc_globalmessage(const char* name,const char* mes); |
---|
| 114 | |
---|
| 115 | void npc_setcells(struct npc_data* nd); |
---|
| 116 | void npc_unsetcells(struct npc_data* nd); |
---|
| 117 | void npc_movenpc(struct npc_data* nd, int x, int y); |
---|
| 118 | int npc_enable(const char* name, int flag); |
---|
| 119 | void npc_setdisplayname(struct npc_data* nd, const char* newname); |
---|
| 120 | void npc_setclass(struct npc_data* nd, short class_); |
---|
| 121 | struct npc_data* npc_name2id(const char* name); |
---|
| 122 | |
---|
| 123 | int npc_get_new_npc_id(void); |
---|
| 124 | |
---|
| 125 | void npc_addsrcfile(const char* name); |
---|
| 126 | void npc_delsrcfile(const char* name); |
---|
| 127 | void npc_parsesrcfile(const char* filepath); |
---|
| 128 | int do_final_npc(void); |
---|
| 129 | int do_init_npc(void); |
---|
| 130 | void npc_event_do_oninit(void); |
---|
| 131 | int npc_do_ontimer(int npc_id, int option); |
---|
| 132 | |
---|
| 133 | int npc_event_do(const char* name); |
---|
| 134 | int npc_event_doall(const char* name); |
---|
| 135 | int npc_event_doall_id(const char* name, int rid); |
---|
| 136 | |
---|
| 137 | int npc_timerevent_start(struct npc_data* nd, int rid); |
---|
| 138 | int npc_timerevent_stop(struct npc_data* nd); |
---|
| 139 | void npc_timerevent_quit(struct map_session_data* sd); |
---|
| 140 | int npc_gettimerevent_tick(struct npc_data* nd); |
---|
| 141 | int npc_settimerevent_tick(struct npc_data* nd, int newtimer); |
---|
| 142 | int npc_remove_map(struct npc_data* nd); |
---|
| 143 | void npc_unload_duplicates (struct npc_data* nd); |
---|
| 144 | int npc_unload(struct npc_data* nd); |
---|
| 145 | int npc_reload(void); |
---|
| 146 | void npc_read_event_script(void); |
---|
| 147 | int npc_script_event(struct map_session_data* sd, enum npce_event type); |
---|
| 148 | |
---|
| 149 | int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points); |
---|
| 150 | |
---|
| 151 | extern struct npc_data* fake_nd; |
---|
| 152 | |
---|
| 153 | #endif /* _NPC_H_ */ |
---|