root/src/map/npc.h @ 9

Revision 1, 4.9 kB (checked in by jinshiro, 17 years ago)
Line 
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
10struct block_list;
11struct npc_data;
12struct view_data;
13
14
15struct npc_timerevent_list {
16        int timer,pos;
17};
18struct npc_label_list {
19        char name[NAME_LENGTH];
20        int pos;
21};
22struct npc_item_list {
23        unsigned int nameid,value;
24};
25
26struct 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
82void npc_chat_finalize(struct npc_data* nd);
83int mob_chat_sub(struct block_list* bl, va_list ap);
84#endif
85
86//Script NPC events.
87enum 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};
98struct view_data* npc_get_viewdata(int class_);
99int npc_chat_sub(struct block_list* bl, va_list ap);
100int npc_event_dequeue(struct map_session_data* sd);
101int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill);
102int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y);
103int npc_touch_areanpc2(struct mob_data *md); // [Skotlex]
104int npc_check_areanpc(int flag, int m, int x, int y, int range);
105int npc_click(struct map_session_data* sd, struct npc_data* nd);
106int npc_scriptcont(struct map_session_data* sd, int id);
107struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
108int npc_buysellsel(struct map_session_data* sd, int id, int type);
109int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
110int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);
111void npc_parse_mob2(struct spawn_data* mob);
112struct 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);
113int npc_globalmessage(const char* name,const char* mes);
114
115void npc_setcells(struct npc_data* nd);
116void npc_unsetcells(struct npc_data* nd);
117void npc_movenpc(struct npc_data* nd, int x, int y);
118int npc_enable(const char* name, int flag);
119void npc_setdisplayname(struct npc_data* nd, const char* newname);
120void npc_setclass(struct npc_data* nd, short class_);
121struct npc_data* npc_name2id(const char* name);
122
123int npc_get_new_npc_id(void);
124
125void npc_addsrcfile(const char* name);
126void npc_delsrcfile(const char* name);
127void npc_parsesrcfile(const char* filepath);
128int do_final_npc(void);
129int do_init_npc(void);
130void npc_event_do_oninit(void);
131int npc_do_ontimer(int npc_id, int option);
132
133int npc_event_do(const char* name);
134int npc_event_doall(const char* name);
135int npc_event_doall_id(const char* name, int rid);
136
137int npc_timerevent_start(struct npc_data* nd, int rid);
138int npc_timerevent_stop(struct npc_data* nd);
139void npc_timerevent_quit(struct map_session_data* sd);
140int npc_gettimerevent_tick(struct npc_data* nd);
141int npc_settimerevent_tick(struct npc_data* nd, int newtimer);
142int npc_remove_map(struct npc_data* nd);
143void npc_unload_duplicates (struct npc_data* nd);
144int npc_unload(struct npc_data* nd);
145int npc_reload(void);
146void npc_read_event_script(void);
147int npc_script_event(struct map_session_data* sd, enum npce_event type);
148
149int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points);
150
151extern struct npc_data* fake_nd;
152
153#endif /* _NPC_H_ */
Note: See TracBrowser for help on using the browser.