1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
9 | * it under the terms of the GNU General Public License as published by |
9 | * under the terms of the GNU General Public License as published by the Free |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
11 | * (at your option) any later version. |
11 | * any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, but |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16 | * GNU General Public License for more details. |
16 | * for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License along |
19 | * along with this program; if not, write to the Free Software |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | * |
21 | * |
22 | * The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | #include <sounds.h> |
27 | #include <sounds.h> |
… | |
… | |
157 | op->x = -1; |
157 | op->x = -1; |
158 | op->y = -1; |
158 | op->y = -1; |
159 | } |
159 | } |
160 | |
160 | |
161 | void |
161 | void |
162 | player::enter_map () |
|
|
163 | { |
|
|
164 | object *tmp = object::create (); |
|
|
165 | |
|
|
166 | EXIT_PATH (tmp) = maplevel; |
|
|
167 | EXIT_X (tmp) = ob->x; |
|
|
168 | EXIT_Y (tmp) = ob->y; |
|
|
169 | ob->enter_exit (tmp); |
|
|
170 | |
|
|
171 | tmp->destroy (); |
|
|
172 | } |
|
|
173 | |
|
|
174 | void |
|
|
175 | player::activate () |
162 | player::activate () |
176 | { |
163 | { |
177 | if (active) |
164 | if (active) |
178 | return; |
165 | return; |
179 | |
166 | |
… | |
… | |
181 | ob->remove (); |
168 | ob->remove (); |
182 | ob->map = 0; |
169 | ob->map = 0; |
183 | ob->activate_recursive (); |
170 | ob->activate_recursive (); |
184 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
171 | CLEAR_FLAG (ob, FLAG_FRIENDLY); |
185 | add_friendly_object (ob); |
172 | add_friendly_object (ob); |
186 | enter_map (); |
|
|
187 | } |
173 | } |
188 | |
174 | |
189 | void |
175 | void |
190 | player::deactivate () |
176 | player::deactivate () |
191 | { |
177 | { |
… | |
… | |
221 | ob->close_container (); //TODO: client-specific |
207 | ob->close_container (); //TODO: client-specific |
222 | |
208 | |
223 | ns->update_look = 0; |
209 | ns->update_look = 0; |
224 | ns->look_position = 0; |
210 | ns->look_position = 0; |
225 | |
211 | |
226 | clear_los (ob); |
212 | clear_los (this); |
227 | |
213 | |
228 | ns->reset_stats (); |
214 | ns->reset_stats (); |
229 | |
215 | |
230 | /* make sure he's a player -- needed because of class change. */ |
216 | /* make sure he's a player -- needed because of class change. */ |
231 | ob->type = PLAYER; // we are paranoid |
217 | ob->type = PLAYER; // we are paranoid |
… | |
… | |
246 | shstr_cmp dragon_ability_force ("dragon_ability_force"); |
232 | shstr_cmp dragon_ability_force ("dragon_ability_force"); |
247 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
233 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
248 | |
234 | |
249 | for (tmp = ob->inv; tmp; tmp = tmp->below) |
235 | for (tmp = ob->inv; tmp; tmp = tmp->below) |
250 | if (tmp->type == FORCE) |
236 | if (tmp->type == FORCE) |
251 | if (tmp->arch->name == dragon_ability_force) |
237 | if (tmp->arch->archname == dragon_ability_force) |
252 | abil = tmp; |
238 | abil = tmp; |
253 | else if (tmp->arch->name == dragon_skin_force) |
239 | else if (tmp->arch->archname == dragon_skin_force) |
254 | skin = tmp; |
240 | skin = tmp; |
255 | |
241 | |
256 | set_dragon_name (ob, abil, skin); |
242 | set_dragon_name (ob, abil, skin); |
257 | } |
243 | } |
258 | |
244 | |
… | |
… | |
325 | // the need for this function can be explained |
311 | // the need for this function can be explained |
326 | // by load_object not returning the object |
312 | // by load_object not returning the object |
327 | void |
313 | void |
328 | player::set_object (object *op) |
314 | player::set_object (object *op) |
329 | { |
315 | { |
330 | ob = op; |
316 | ob = observe = op; |
331 | ob->contr = this; /* this aren't yet in archetype */ |
317 | ob->contr = this; /* this aren't yet in archetype */ |
332 | |
318 | |
333 | ob->speed = 1.0f; |
319 | ob->speed = 1.0f; |
334 | ob->speed_left = 0.5f; |
320 | ob->speed_left = 0.5f; |
335 | |
321 | |
336 | ob->direction = 5; /* So player faces south */ |
322 | ob->direction = 5; /* So player faces south */ |
|
|
323 | } |
|
|
324 | |
|
|
325 | void |
|
|
326 | player::set_observe (object *op) |
|
|
327 | { |
|
|
328 | observe = op ? op : ob; |
|
|
329 | do_los = 1; |
337 | } |
330 | } |
338 | |
331 | |
339 | player::player () |
332 | player::player () |
340 | { |
333 | { |
341 | /* There are some elements we want initialised to non zero value - |
334 | /* There are some elements we want initialised to non zero value - |
… | |
… | |
921 | if (*first_map_ext_path) |
914 | if (*first_map_ext_path) |
922 | { |
915 | { |
923 | object *tmp; |
916 | object *tmp; |
924 | char mapname[MAX_BUF]; |
917 | char mapname[MAX_BUF]; |
925 | |
918 | |
926 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->name); |
919 | snprintf (mapname, MAX_BUF - 1, "%s/%s", &first_map_ext_path, &ob->arch->archname); |
927 | tmp = object::create (); |
920 | tmp = object::create (); |
928 | EXIT_PATH (tmp) = mapname; |
921 | EXIT_PATH (tmp) = mapname; |
929 | EXIT_X (tmp) = ob->x; |
922 | EXIT_X (tmp) = ob->x; |
930 | EXIT_Y (tmp) = ob->y; |
923 | EXIT_Y (tmp) = ob->y; |
931 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
924 | ob->enter_exit (tmp); /* we don't really care if it succeeded; |
… | |
… | |
1113 | if (tmp->name != NULL) |
1106 | if (tmp->name != NULL) |
1114 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1107 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1115 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1108 | &tmp->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1116 | else |
1109 | else |
1117 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1110 | sprintf (putstring, "item name: %s item type: %d weight/value: %d", |
1118 | &tmp->arch->name, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1111 | &tmp->arch->archname, tmp->type, (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1119 | |
1112 | |
1120 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
1113 | new_draw_info (NDI_UNIQUE, 0, op, putstring); |
1121 | } |
1114 | } |
1122 | |
1115 | |
1123 | /* philosophy: |
1116 | /* philosophy: |
… | |
… | |
1316 | /* careful: chairs and tables are weapons! */ |
1309 | /* careful: chairs and tables are weapons! */ |
1317 | if (op->contr->mode & PU_ALLWEAPON) |
1310 | if (op->contr->mode & PU_ALLWEAPON) |
1318 | { |
1311 | { |
1319 | if (tmp->type == WEAPON && tmp->name != NULL) |
1312 | if (tmp->type == WEAPON && tmp->name != NULL) |
1320 | { |
1313 | { |
1321 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && |
1314 | if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->archname, "table") == NULL && |
1322 | strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) |
1315 | strstr (tmp->name, "chair") && strstr (tmp->arch->archname, "chair") == NULL) |
1323 | { |
1316 | { |
1324 | pick_up (op, tmp); |
1317 | pick_up (op, tmp); |
1325 | continue; |
1318 | continue; |
1326 | } |
1319 | } |
1327 | } |
1320 | } |
1328 | |
1321 | |
1329 | if (tmp->type == WEAPON && tmp->name == NULL) |
1322 | if (tmp->type == WEAPON && tmp->name == NULL) |
1330 | { |
1323 | { |
1331 | if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) |
1324 | if (strstr (tmp->arch->archname, "table") == NULL && strstr (tmp->arch->archname, "chair") == NULL) |
1332 | { |
1325 | { |
1333 | pick_up (op, tmp); |
1326 | pick_up (op, tmp); |
1334 | continue; |
1327 | continue; |
1335 | } |
1328 | } |
1336 | } |
1329 | } |
… | |
… | |
1361 | if (tmp->name != NULL) |
1354 | if (tmp->name != NULL) |
1362 | { |
1355 | { |
1363 | fprintf (stderr, "%s", tmp->name); |
1356 | fprintf (stderr, "%s", tmp->name); |
1364 | } |
1357 | } |
1365 | else |
1358 | else |
1366 | fprintf (stderr, "%s", tmp->arch->name); |
1359 | fprintf (stderr, "%s", tmp->arch->archname); |
1367 | fprintf (stderr, ",%d] = ", tmp->type); |
1360 | fprintf (stderr, ",%d] = ", tmp->type); |
1368 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1361 | fprintf (stderr, "%d\n", (int) (query_cost (tmp, op, F_TRUE) * 100 / (tmp->weight * MAX (tmp->nrof, 1)))); |
1369 | #endif |
1362 | #endif |
1370 | continue; |
1363 | continue; |
1371 | } |
1364 | } |
… | |
… | |
3433 | /* forces in the treasurelist can alter the player's stats */ |
3426 | /* forces in the treasurelist can alter the player's stats */ |
3434 | object *skin; |
3427 | object *skin; |
3435 | |
3428 | |
3436 | /* first get the dragon skin force */ |
3429 | /* first get the dragon skin force */ |
3437 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
3430 | shstr_cmp dragon_skin_force ("dragon_skin_force"); |
3438 | for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below) |
3431 | for (skin = who->inv; skin && !(skin->arch->archname == dragon_skin_force); skin = skin->below) |
3439 | ; |
3432 | ; |
3440 | |
3433 | |
3441 | if (!skin) |
3434 | if (!skin) |
3442 | return; |
3435 | return; |
3443 | |
3436 | |