ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/player.h
Revision: 1.94
Committed: Wed Nov 4 17:24:00 2009 UTC (14 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.93: +3 -1 lines
Log Message:
interim checkin, new spell

File Contents

# User Rev Content
1 root 1.1 /*
2 root 1.74 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 pippijn 1.45 *
4 root 1.79 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.59 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992,2007 Frank Tore Johansen
7 pippijn 1.45 *
8 root 1.92 * Deliantra is free software: you can redistribute it and/or modify it under
9     * the terms of the Affero GNU General Public License as published by the
10     * Free Software Foundation, either version 3 of the License, or (at your
11     * option) any later version.
12 pippijn 1.45 *
13 root 1.64 * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17 pippijn 1.45 *
18 root 1.92 * You should have received a copy of the Affero GNU General Public License
19     * and the GNU General Public License along with this program. If not, see
20     * <http://www.gnu.org/licenses/>.
21 root 1.59 *
22 root 1.74 * The authors can be reached via e-mail to <support@deliantra.net>
23 pippijn 1.45 */
24 root 1.93 #ifndef PLAYER_H_
25     #define PLAYER_H_
26 root 1.1
27 root 1.16 enum bowtype_t
28     {
29 root 1.50 bow_normal = 0,
30     bow_threewide = 1,
31 root 1.16 bow_spreadshot = 2,
32 root 1.50 bow_n = 3, /* must stay at 3 */
33 root 1.16 bow_ne = 4,
34 root 1.50 bow_e = 5,
35 root 1.16 bow_se = 6,
36 root 1.50 bow_s = 7,
37 root 1.16 bow_sw = 8,
38 root 1.50 bow_w = 9,
39 root 1.16 bow_nw = 10, /* must stay at 10 */
40     bow_bestarrow = 11
41     };
42    
43     enum petmode_t
44     {
45     pet_normal = 0,
46 root 1.50 pet_sad = 1,
47 root 1.16 pet_defend = 2,
48 root 1.50 pet_arena = 3,
49 root 1.16 };
50    
51     enum usekeytype
52     {
53     key_inventory = 0,
54 root 1.50 keyrings = 1,
55     containers = 2,
56 root 1.16 };
57 root 1.1
58     /* This is used to control what to do when we need to unapply
59     * an object before we can apply another one.
60     */
61 root 1.16 enum unapplymode
62     {
63     unapply_nochoice = 0, /* Will unapply objects when there no choice to unapply */
64     unapply_never = 1, /* will not unapply objects automatically */
65     unapply_always = 2 /* Will unapply whatever is necessary - this goes beyond */
66     /* no choice - if there are multiple ojbect of the same type */
67     /* that need to be unapplied, there is no way for the player */
68     /* to control which of these will be unapplied. */
69     };
70    
71     /* not really the player, but tied pretty closely */
72 root 1.38 INTERFACE_CLASS (partylist)
73 root 1.16 struct partylist
74     {
75 root 1.38 char *ACC (RW, partyleader);
76     char ACC (RW, passwd)[9];
77     partylist *ACC (RW, next);
78     char *ACC (RW, partyname);
79 root 1.1
80 root 1.16 struct party_kill
81     {
82     char killer[MAX_NAME + 1], dead[MAX_NAME + 1];
83     sint64 exp;
84     } party_kills[PARTY_KILL_LOG];
85 root 1.38
86     sint64 ACC (RW, total_exp);
87     uint32 ACC (RW, kills);
88 root 1.16 };
89 root 1.1
90 root 1.55 // used for pet monster logic etc.
91     static bool
92     same_party (partylist *a, partylist *b)
93     {
94     return a == b && a;
95     }
96    
97 root 1.35 INTERFACE_CLASS (player)
98     struct player : zero_initialised, attachable
99 root 1.6 {
100 root 1.67 client *ACC (RO, ns); /* Socket information for this player, ALWAYS valid when a player is on a map */
101     object *ACC (RW, ob); /* The object representing the player, ALWAYS valid */
102 root 1.62 object_vector_index ACC (RO, active);
103 root 1.43
104 root 1.51 bowtype_t ACC (RW, bowtype); /* which firemode? */
105     petmode_t ACC (RW, petmode); /* which petmode? */
106     usekeytype ACC (RW, usekeys); /* Method for finding keys for doors */
107     unapplymode ACC (RW, unapply); /* Method for auto unapply */
108     uint32 ACC (RW, count); /* Any numbers typed before a command */
109     uint32 ACC (RW, mode); /* Mode of player for pickup. */
110    
111 root 1.91 int ACC (RW, digestion); /* Any bonuses/penalties to digestion */
112     int ACC (RW, gen_hp); /* Bonuses to regeneration speed of hp */
113     int ACC (RW, gen_sp); /* Bonuses to regeneration speed of sp */
114     int ACC (RW, gen_sp_armour); /* Penalty to sp regen from armour */
115     int ACC (RW, gen_grace); /* Bonuses to regeneration speed of grace */
116     int ACC (RW, item_power); /* Total item power of objects equipped */
117 root 1.82 uint8 ACC (RW, gender); /* 0 male, 1 female, others not yet defined */
118     uint8 ACC (RW, hintmode); /* 0 full, 1 hint, 2 disable */
119 root 1.16
120     /* Try to put all the bitfields together - saves some small amount of memory */
121 root 1.43 bool ACC (RW, braced); /* Will not move if braced, only attack */
122     bool ACC (RW, tmp_invis); /* Will invis go away when we attack ? */
123     bool ACC (RW, do_los); /* If true, need to call update_los() in draw(), and clear */
124     bool ACC (RW, fire_on); /* Player should fire object, not move */
125     bool ACC (RW, run_on); /* Player should keep moving in dir until run is off */
126     bool ACC (RW, peaceful); /* If set, won't attack friendly creatures */
127     bool ACC (RW, hidden); /* If True, player (DM) is hidden from view */
128 root 1.76 bool ACC (RW, dirty); // set if player is dirty (not reliable yet!)
129 root 1.16
130 root 1.18 float ACC (RW, weapon_sp); /* Penalties to speed when fighting w speed >ws/10 */
131 root 1.57 float ACC (RW, weapon_sp_left); // same as speed_left, but for attacks
132 root 1.18 living ACC (RO, orig_stats); /* Permanent real stats of player */
133 root 1.44 object_ptr last_skill_ob[NUM_SKILLS]; /* the exp object */
134 root 1.18 object_ptr ACC (RW, last_used); /* Pointer to object last picked or applied */
135 root 1.16
136 root 1.53 object_ptr ACC (RW, combat_ob); // which weapon/bow/skill to use for direct attacks
137     object_ptr ACC (RW, ranged_ob); // which skill/item/spell to use for ranged attacks
138 root 1.51 object_ptr ACC (RW, golem); // the currently controlled golem
139 root 1.94 object_ptr ACC (RW, observe); // the object that is being observed (never 0)
140     object_ptr ACC (RW, viewpoint); // the object that is being viewed in the map (never 0)
141 root 1.51
142 root 1.18 sint16 ACC (RW, bed_x), ACC (RW, bed_y); /* x,y - coordinates of respawn (savebed) */
143 root 1.39 shstr ACC (RW, savebed_map); /* map where player will respawn after death */
144     shstr ACC (RW, maplevel); /* On which level is the player? */
145 root 1.18 char ACC (RW, spellparam)[MAX_BUF]; /* What param to add to spells */
146 root 1.16
147 root 1.18 char ACC (RW, own_title)[MAX_NAME]; /* Title the player has chosen for themself */
148 root 1.16 /* Note that for dragon players, this is filled in for them */
149 root 1.19 char ACC (RW, title)[64]; /* Default title, like fighter, wizard, etc */
150 root 1.16
151 root 1.34 sint8 ACC (RW, levhp[11]); /* What the player gained on that level */
152     sint8 ACC (RW, levsp[11]); /* Same for sp */
153     sint8 ACC (RW, levgrace[11]); /* And same for grace */
154 root 1.16
155 root 1.77 object_ptr ACC (RW, killer); /* Who last tried to kill this player (this object is usually destroyed) */
156 root 1.16
157 root 1.31 char write_buf[MAX_BUF]; /* Holds arbitrary input from client */ /* should go */
158 root 1.18 char ACC (RW, password)[16]; /* 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */
159 root 1.1
160 root 1.18 partylist *ACC (RW, party); /* Party this player is part of */
161     partylist *ACC (RW, party_to_join); /* used when player wants to join a party */
162 root 1.16 /* but we will have to get password first */
163     /* so we have to remember which party to */
164     /* join */
165 root 1.18 char ACC (RW, search_str)[MAX_BUF]; /* Item we are looking for */
166     sint16 ACC (RW, encumbrance); /* How much our player is encumbered */
167     uint16 ACC (RW, outputs_sync); /* How often to print, no matter what */
168     uint16 ACC (RW, outputs_count); /* Print if this count is exceeded */
169     object_ptr ACC (RW, mark); /* marked object */
170 root 1.16 /* Special DM fields */
171     tag_t *stack_items; /* Item stack for patch/dump/... commands */
172 root 1.18 int ACC (RW, stack_position); /* Current stack position, 0 for no item */
173 root 1.85 sint8 los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */
174     /* the player can see. For maps smaller than */
175     /* MAP_CLIENT_.., the center is used */
176    
177     // return the los value for the given coordinate
178     MTH sint8 blocked_los (int dx, int dy) const
179     {
180     dx += LOS_X0;
181     dy += LOS_Y0;
182    
183     return 0 <= dx && dx < MAP_CLIENT_X
184     && 0 <= dy && dy < MAP_CLIENT_Y
185     ? los[dx][dy] : LOS_BLOCKED;
186     }
187    
188     // unchecked variant
189     sint8 blocked_los_uc (int dx, int dy) const
190     {
191     return los[dx + LOS_X0][dy + LOS_Y0];
192     }
193 root 1.16
194 root 1.86 MTH void clear_los (sint8 value = LOS_BLOCKED);
195 root 1.88 MTH void update_los ();
196 root 1.86
197 root 1.31 shstr ACC (RW, invis_race); /* What race invisible to? */
198 root 1.13
199 root 1.77 MTH const char *killer_name () const; // makes a string out of ->killer
200    
201 root 1.36 MTH static player *create ();
202 root 1.73 static player *find (const_utf8_string name);
203 root 1.43
204     static player *load_pl (object_thawer &thawer);
205 root 1.73 MTH static player *load_pl (object_thawer *thawer) { return load_pl (*thawer); }
206 root 1.43
207 root 1.83 MTH void link_skills ();
208 root 1.90 MTH object *find_skill (shstr_cmp name) const;
209 root 1.83
210 root 1.43 bool save_pl (object_freezer &freezer);
211     MTH bool save_pl (const char *path);
212    
213 root 1.35 void do_destroy ();
214     void gather_callbacks (AV *&callbacks, event_type event) const;
215 root 1.31
216 root 1.82 MTH dynbuf_text *expand_cfpod (const char *cfpod) const;
217    
218 root 1.78 MTH void touch () { dirty = true; } // need to touch when logged out and changed
219    
220 root 1.65 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0) const
221     {
222     if (ns)
223     ns->play_sound (sound, dx, dy);
224     }
225    
226 root 1.46 // wether the player can "see" this mapspace or not, decided by los
227 root 1.89 // 0 - bright, 3 dark, 4 too dark, 100 blocked or out of range
228     MTH sint8 darkness_at (maptile *map, int x, int y) const;
229 root 1.46
230 root 1.36 MTH void connect (client *ns);
231     MTH void disconnect ();
232 root 1.31
233 root 1.43 MTH void activate ();
234     MTH void deactivate ();
235    
236 root 1.48 MTH void chargen_race_done ();
237     MTH void chargen_race_next ();
238    
239 root 1.80 MTH void set_observe (object_ornull *ob);
240 root 1.94 MTH void set_viewpoint (object_ornull *ob);
241 root 1.60
242 root 1.68 void send_msg (int color, const char *type, const char *msg)
243     {
244     ns->send_msg (color, type, msg);
245     }
246    
247     // a prominent box that can easily be escaped away or so
248     // should be used for informative output such as who, maps etc.
249     // will stay on-screen
250 root 1.75 MTH void infobox (const char *title, const char *msg, int color = NDI_BLACK);
251 root 1.68
252     // a prominent msg that signifies some important event,
253     // an improvement potion effect potion. should not be long.
254     // might time out after a while
255 root 1.75 MTH void statusmsg (const char *msg, int color = NDI_BLACK);
256 root 1.68
257     // a prominent box that signifies some error such as a failed
258     // improvement potion. should not be long.
259 root 1.75 MTH void failmsg (const char *msg, int color = NDI_RED);
260 root 1.68
261 root 1.31 ~player ();
262    
263     private:
264     void set_object (object *op);
265     player ();
266 root 1.16 };
267 root 1.13
268 root 1.43 typedef object_vector<player, &player::active> playervec;
269    
270     extern playervec players;
271    
272     #define for_all_players(var) \
273 root 1.65 for (unsigned _i = 0; _i < ::players.size (); ++_i) \
274     statementvar (player *, var, ::players [_i])
275 root 1.43
276 root 1.87 #define for_all_players_on_map(var,mapp) \
277     for_all_players(var) \
278     if ((var)->ob->map == (mapp))
279    
280 root 1.68 inline void
281     object::statusmsg (const char *msg, int color)
282     {
283     if (expect_true (contr)) contr->statusmsg (msg, color);
284     }
285    
286     inline void
287 root 1.69 object::failmsg (const char *msg, int color)
288 root 1.68 {
289 root 1.69 if (expect_true (contr)) contr->failmsg (msg, color);
290 root 1.68 }
291 root 1.93
292     #endif