… | |
… | |
116 | |
116 | |
117 | news[0] = '\0'; |
117 | news[0] = '\0'; |
118 | subject[0] = '\0'; |
118 | subject[0] = '\0'; |
119 | size = 0; |
119 | size = 0; |
120 | |
120 | |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp)) |
122 | { |
122 | { |
123 | if (*buf == '#') |
123 | if (*buf == '#') |
124 | continue; |
124 | continue; |
125 | |
125 | |
126 | if (*buf == '%') |
126 | if (*buf == '%') |
127 | { /* send one news */ |
127 | { /* send one news */ |
128 | if (size > 0) |
128 | if (size > 0) |
129 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
129 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", (char *)"%s\n%s", subject, news); /*send previously read news */ |
130 | |
130 | |
131 | strcpy (subject, buf + 1); |
131 | strcpy (subject, buf + 1); |
132 | strip_endline (subject); |
132 | strip_endline (subject); |
133 | size = 0; |
133 | size = 0; |
134 | news[0] = '\0'; |
134 | news[0] = '\0'; |
… | |
… | |
144 | size += strlen (buf); |
144 | size += strlen (buf); |
145 | } |
145 | } |
146 | } |
146 | } |
147 | |
147 | |
148 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
148 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
149 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", "%s\n%s", subject, news); |
149 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", (char *)"%s\n%s", subject, news); |
150 | close_and_delete (fp, comp); |
150 | close_and_delete (fp, comp); |
151 | } |
151 | } |
152 | |
152 | |
153 | /* This loads the first map an puts the player on it. */ |
153 | /* This loads the first map an puts the player on it. */ |
154 | static void |
154 | static void |
… | |
… | |
197 | remove_friendly_object (ob); |
197 | remove_friendly_object (ob); |
198 | ob->deactivate_recursive (); |
198 | ob->deactivate_recursive (); |
199 | maplevel = ob->map->path; |
199 | maplevel = ob->map->path; |
200 | ob->remove (); |
200 | ob->remove (); |
201 | ob->map = 0; |
201 | ob->map = 0; |
|
|
202 | party = 0; |
202 | |
203 | |
203 | // for weird reasons, this is often "ob", keeping a circular reference |
204 | // for weird reasons, this is often "ob", keeping a circular reference |
204 | ranges [range_skill] = 0; |
205 | ranges [range_skill] = 0; |
205 | |
206 | |
206 | players.erase (this); |
207 | players.erase (this); |
… | |
… | |
236 | link_player_skills (ob); |
237 | link_player_skills (ob); |
237 | |
238 | |
238 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
239 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
239 | |
240 | |
240 | assign (title, ob->arch->clone.name); |
241 | assign (title, ob->arch->clone.name); |
241 | |
|
|
242 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
|
|
243 | * from the class, and not race. I don't see any way to get the class information |
|
|
244 | * to then update this. I don't think this will actually break anything - anyone |
|
|
245 | * that can use armour should be able to use a shield. What this may 'break' |
|
|
246 | * are features new characters get, eg, if someone starts up with a Q, they |
|
|
247 | * should be able to use a shield. However, old Q's won't get that advantage. |
|
|
248 | */ |
|
|
249 | if (QUERY_FLAG (ob, FLAG_USE_ARMOUR)) |
|
|
250 | SET_FLAG (ob, FLAG_USE_SHIELD); |
|
|
251 | |
242 | |
252 | /* if it's a dragon player, set the correct title here */ |
243 | /* if it's a dragon player, set the correct title here */ |
253 | if (is_dragon_pl (ob)) |
244 | if (is_dragon_pl (ob)) |
254 | { |
245 | { |
255 | object *tmp, *abil = 0, *skin = 0; |
246 | object *tmp, *abil = 0, *skin = 0; |
… | |
… | |
300 | ns->reset_stats (); |
291 | ns->reset_stats (); |
301 | ns->pl = 0; |
292 | ns->pl = 0; |
302 | this->ns = 0; |
293 | this->ns = 0; |
303 | } |
294 | } |
304 | |
295 | |
|
|
296 | if (ob) |
305 | ob->close_container (); //TODO: client-specific |
297 | ob->close_container (); //TODO: client-specific |
|
|
298 | |
306 | deactivate (); |
299 | deactivate (); |
307 | } |
300 | } |
308 | |
301 | |
309 | // the need for this function can be explained |
302 | // the need for this function can be explained |
310 | // by load_object not returning the object |
303 | // by load_object not returning the object |
311 | void |
304 | void |
312 | player::set_object (object *op) |
305 | player::set_object (object *op) |
313 | { |
306 | { |
314 | ob = op; |
307 | ob = op; |
315 | ob->contr = this; /* this aren't yet in archetype */ |
308 | ob->contr = this; /* this aren't yet in archetype */ |
316 | |
309 | |
317 | ob->speed_left = 0.5; |
310 | ob->speed_left = 0.5; |
318 | ob->speed = 1.0; |
311 | ob->speed = 1.0; |
319 | ob->direction = 5; /* So player faces south */ |
312 | ob->direction = 5; /* So player faces south */ |
320 | ob->stats.wc = 2; |
|
|
321 | ob->run_away = 25; /* Then we panick... */ |
|
|
322 | |
|
|
323 | ob->roll_stats (); |
|
|
324 | } |
313 | } |
325 | |
314 | |
326 | player::player () |
315 | player::player () |
327 | { |
316 | { |
328 | /* There are some elements we want initialised to non zero value - |
317 | /* There are some elements we want initialised to non zero value - |
329 | * we deal with that below this point. |
318 | * we deal with that below this point. |
330 | */ |
319 | */ |
331 | outputs_sync = 16; /* Every 2 seconds */ |
320 | outputs_sync = 6; /* Every 2 seconds */ |
332 | outputs_count = 8; /* Keeps present behaviour */ |
321 | outputs_count = 10; /* Keeps present behaviour */ |
333 | unapply = unapply_nochoice; |
322 | unapply = unapply_nochoice; |
334 | |
323 | |
335 | savebed_map = first_map_path; /* Init. respawn position */ |
324 | savebed_map = first_map_path; /* Init. respawn position */ |
336 | |
325 | |
337 | gen_sp_armour = 10; |
326 | gen_sp_armour = 10; |
… | |
… | |
372 | player::create () |
361 | player::create () |
373 | { |
362 | { |
374 | player *pl = new player; |
363 | player *pl = new player; |
375 | |
364 | |
376 | pl->set_object (arch_to_object (get_player_archetype (0))); |
365 | pl->set_object (arch_to_object (get_player_archetype (0))); |
|
|
366 | |
|
|
367 | pl->ob->roll_stats (); |
|
|
368 | pl->ob->stats.wc = 2; |
|
|
369 | pl->ob->run_away = 25; /* Then we panick... */ |
|
|
370 | |
377 | set_first_map (pl->ob); |
371 | set_first_map (pl->ob); |
378 | |
372 | |
379 | return pl; |
373 | return pl; |
380 | } |
374 | } |
381 | |
375 | |
… | |
… | |
883 | char buf[MAX_BUF]; |
877 | char buf[MAX_BUF]; |
884 | |
878 | |
885 | /* this must before then initial items are given */ |
879 | /* this must before then initial items are given */ |
886 | esrv_new_player (op->contr, op->weight + op->carrying); |
880 | esrv_new_player (op->contr, op->weight + op->carrying); |
887 | |
881 | |
888 | treasurelist *tl = find_treasurelist ("starting_wealth"); |
882 | treasurelist *tl = treasurelist::find ("starting_wealth"); |
889 | if (tl) |
883 | if (tl) |
890 | create_treasure (tl, op, 0, 0, 0); |
884 | create_treasure (tl, op, 0, 0, 0); |
891 | |
885 | |
892 | INVOKE_PLAYER (BIRTH, op->contr); |
886 | INVOKE_PLAYER (BIRTH, op->contr); |
893 | INVOKE_PLAYER (LOGIN, op->contr); |
887 | INVOKE_PLAYER (LOGIN, op->contr); |
… | |
… | |
1036 | int |
1030 | int |
1037 | check_pick (object *op) |
1031 | check_pick (object *op) |
1038 | { |
1032 | { |
1039 | object *tmp, *next; |
1033 | object *tmp, *next; |
1040 | int stop = 0; |
1034 | int stop = 0; |
1041 | int j, k, wvratio; |
1035 | int wvratio; |
1042 | char putstring[128], tmpstr[16]; |
1036 | char putstring[128]; |
1043 | |
1037 | |
1044 | /* if you're flying, you cna't pick up anything */ |
1038 | /* if you're flying, you cna't pick up anything */ |
1045 | if (op->move_type & MOVE_FLYING) |
1039 | if (op->move_type & MOVE_FLYING) |
1046 | return 1; |
1040 | return 1; |
1047 | |
1041 | |
… | |
… | |
2262 | * Returns true if there are more actions we can do. |
2256 | * Returns true if there are more actions we can do. |
2263 | */ |
2257 | */ |
2264 | int |
2258 | int |
2265 | handle_newcs_player (object *op) |
2259 | handle_newcs_player (object *op) |
2266 | { |
2260 | { |
2267 | if (op->contr->hidden) |
|
|
2268 | { |
|
|
2269 | op->invisible = 1000; |
|
|
2270 | /* the socket code flashes the player visible/invisible |
|
|
2271 | * depending on the value of invisible, so we need to |
|
|
2272 | * alternate it here for it to work correctly. |
|
|
2273 | */ |
|
|
2274 | if (pticks & 2) |
|
|
2275 | op->invisible--; |
|
|
2276 | } |
|
|
2277 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
|
|
2278 | { |
|
|
2279 | op->invisible--; |
|
|
2280 | if (!op->invisible) |
|
|
2281 | { |
|
|
2282 | make_visible (op); |
|
|
2283 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
|
|
2284 | } |
|
|
2285 | } |
|
|
2286 | |
|
|
2287 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2261 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2288 | { |
2262 | { |
2289 | flee_player (op); |
2263 | flee_player (op); |
2290 | /* If player is still scared, that is his action for this tick */ |
2264 | /* If player is still scared, that is his action for this tick */ |
2291 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
… | |
… | |
2445 | int rate_grace = 2000; |
2419 | int rate_grace = 2000; |
2446 | const int max_hp = 1; |
2420 | const int max_hp = 1; |
2447 | const int max_sp = 1; |
2421 | const int max_sp = 1; |
2448 | const int max_grace = 1; |
2422 | const int max_grace = 1; |
2449 | |
2423 | |
|
|
2424 | if (op->contr->hidden) |
|
|
2425 | { |
|
|
2426 | op->invisible = 1000; |
|
|
2427 | /* the socket code flashes the player visible/invisible |
|
|
2428 | * depending on the value of invisible, so we need to |
|
|
2429 | * alternate it here for it to work correctly. |
|
|
2430 | */ |
|
|
2431 | if (pticks & 2) |
|
|
2432 | op->invisible--; |
|
|
2433 | } |
|
|
2434 | else if (op->invisible && !(QUERY_FLAG (op, FLAG_MAKE_INVIS))) |
|
|
2435 | { |
|
|
2436 | if (!op->invisible--) |
|
|
2437 | { |
|
|
2438 | make_visible (op); |
|
|
2439 | new_draw_info (NDI_UNIQUE, 0, op, "Your invisibility spell runs out."); |
|
|
2440 | } |
|
|
2441 | } |
|
|
2442 | |
2450 | if (op->contr->outputs_sync) |
2443 | if (op->contr->outputs_sync) |
2451 | { |
|
|
2452 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2444 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2453 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2445 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2454 | flush_output_element (op, &op->contr->outputs[i]); |
2446 | flush_output_element (op, &op->contr->outputs[i]); |
2455 | } |
|
|
2456 | |
2447 | |
2457 | if (op->contr->ns->state == ST_PLAYING) |
2448 | if (op->contr->ns->state == ST_PLAYING) |
2458 | { |
2449 | { |
2459 | /* these next three if clauses make it possible to SLOW DOWN |
2450 | /* these next three if clauses make it possible to SLOW DOWN |
2460 | hp/grace/spellpoint regeneration. */ |
2451 | hp/grace/spellpoint regeneration. */ |
… | |
… | |
2916 | op->stats.hp = op->stats.maxhp; |
2907 | op->stats.hp = op->stats.maxhp; |
2917 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2908 | op->stats.sp = MAX (op->stats.sp, op->stats.maxsp); |
2918 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2909 | op->stats.grace = MAX (op->stats.grace, op->stats.maxgrace); |
2919 | |
2910 | |
2920 | /* |
2911 | /* |
2921 | * Check to see if the player is in a shop. IF so, then check to see if |
|
|
2922 | * the player has any unpaid items. If so, remove them and put them back |
2912 | * Check to see if the player has any unpaid items. If so, remove them |
2923 | * in the map. |
2913 | * and put them back in the map. |
2924 | */ |
2914 | */ |
2925 | |
|
|
2926 | if (is_in_shop (op)) |
|
|
2927 | remove_unpaid_objects (op->inv, op); |
2915 | remove_unpaid_objects (op->inv, op); |
2928 | |
2916 | |
2929 | /****************************************/ |
2917 | /****************************************/ |
2930 | /* */ |
2918 | /* */ |
2931 | /* Move player to his current respawn- */ |
2919 | /* Move player to his current respawn- */ |
2932 | /* position (usually last savebed) */ |
2920 | /* position (usually last savebed) */ |
… | |
… | |
3077 | if (op->type == PLAYER) |
3065 | if (op->type == PLAYER) |
3078 | { |
3066 | { |
3079 | op->contr->tmp_invis = 0; |
3067 | op->contr->tmp_invis = 0; |
3080 | op->contr->invis_race = 0; |
3068 | op->contr->invis_race = 0; |
3081 | } |
3069 | } |
|
|
3070 | |
3082 | update_object (op, UP_OBJ_FACE); |
3071 | update_object (op, UP_OBJ_CHANGE); |
3083 | } |
3072 | } |
3084 | |
3073 | |
3085 | int |
3074 | int |
3086 | is_true_undead (object *op) |
3075 | is_true_undead (object *op) |
3087 | { |
3076 | { |
3088 | object *tmp = NULL; |
|
|
3089 | |
|
|
3090 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3077 | if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) |
3091 | return 1; |
3078 | return 1; |
3092 | |
3079 | |
3093 | return 0; |
3080 | return 0; |
3094 | } |
3081 | } |
… | |
… | |
3382 | char buf[MAX_BUF]; /* tmp. string buffer */ |
3369 | char buf[MAX_BUF]; /* tmp. string buffer */ |
3383 | int i = 0, j = 0; |
3370 | int i = 0, j = 0; |
3384 | |
3371 | |
3385 | /* get the appropriate treasurelist */ |
3372 | /* get the appropriate treasurelist */ |
3386 | if (atnr == ATNR_FIRE) |
3373 | if (atnr == ATNR_FIRE) |
3387 | trlist = find_treasurelist ("dragon_ability_fire"); |
3374 | trlist = treasurelist::find ("dragon_ability_fire"); |
3388 | else if (atnr == ATNR_COLD) |
3375 | else if (atnr == ATNR_COLD) |
3389 | trlist = find_treasurelist ("dragon_ability_cold"); |
3376 | trlist = treasurelist::find ("dragon_ability_cold"); |
3390 | else if (atnr == ATNR_ELECTRICITY) |
3377 | else if (atnr == ATNR_ELECTRICITY) |
3391 | trlist = find_treasurelist ("dragon_ability_elec"); |
3378 | trlist = treasurelist::find ("dragon_ability_elec"); |
3392 | else if (atnr == ATNR_POISON) |
3379 | else if (atnr == ATNR_POISON) |
3393 | trlist = find_treasurelist ("dragon_ability_poison"); |
3380 | trlist = treasurelist::find ("dragon_ability_poison"); |
3394 | |
3381 | |
3395 | if (trlist == NULL || who->type != PLAYER) |
3382 | if (trlist == NULL || who->type != PLAYER) |
3396 | return; |
3383 | return; |
3397 | |
3384 | |
3398 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |
3385 | for (i = 0, tr = trlist->items; tr != NULL && i < level - 1; tr = tr->next, i++); |