| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include "global.h" |
| 19 |
|
| 20 |
#include <string.h> |
| 21 |
|
| 22 |
#include "ob_methods.h" |
| 23 |
#include "ob_types.h" |
| 24 |
#include "sounds.h" |
| 25 |
#include "sproto.h" |
| 26 |
|
| 27 |
static method_ret player_changer_type_process(ob_methods *context, object *op); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
void init_type_player_changer(void) { |
| 33 |
register_process(PLAYER_CHANGER, player_changer_type_process); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
static method_ret player_changer_type_process(ob_methods *context, object *op) { |
| 50 |
object *player; |
| 51 |
char c; |
| 52 |
|
| 53 |
if (!op->above || !EXIT_PATH(op)) |
| 54 |
return METHOD_OK; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
if (op->above->type == PLAYER) { |
| 60 |
|
| 61 |
if (execute_event(op, EVENT_TRIGGER, op->above, NULL, NULL, SCRIPT_FIX_NOTHING) != 0) |
| 62 |
return METHOD_OK; |
| 63 |
player = op->above; |
| 64 |
FOR_INV_PREPARE(op, walk) |
| 65 |
apply_changes_to_player(player, walk, AC_PLAYER_STAT_LIMIT); |
| 66 |
FOR_INV_FINISH(); |
| 67 |
|
| 68 |
fix_object(player); |
| 69 |
esrv_send_inventory(op->above, op->above); |
| 70 |
esrv_update_item(UPD_FACE, op->above, op->above); |
| 71 |
|
| 72 |
|
| 73 |
sscanf(EXIT_PATH(op), "%c", &c); |
| 74 |
if (c == '/') { |
| 75 |
safe_strncpy(player->contr->savebed_map, EXIT_PATH(op), |
| 76 |
sizeof(player->contr->savebed_map)); |
| 77 |
player->contr->bed_x = EXIT_X(op); |
| 78 |
player->contr->bed_y = EXIT_Y(op); |
| 79 |
} else |
| 80 |
LOG(llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", EXIT_PATH(op)); |
| 81 |
|
| 82 |
enter_exit(op->above, op); |
| 83 |
save_player(player, 1); |
| 84 |
} |
| 85 |
|
| 86 |
return METHOD_OK; |
| 87 |
} |