short at_scavenger_room(struct Thing *thing) { struct CreatureControl *cctrl; struct CreatureStats *crstat; struct Dungeon *dungeon; struct Room *room; //return _DK_at_scavenger_room(thing); room = get_room_thing_is_on(thing); if (!room_initially_valid_as_type_for_thing(room, RoK_SCAVENGER, thing)) { WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(thing),(int)thing->index); set_start_state(thing); return 0; } cctrl = creature_control_get_from_thing(thing); crstat = creature_stats_get_from_thing(thing); dungeon = get_dungeon(thing->owner); if (crstat->scavenger_cost >= dungeon->total_money_owned) { if (is_my_player_number(thing->owner)) output_message(SMsg_NoGoldToScavenge, MESSAGE_DELAY_TREASURY, true); set_start_state(thing); return 0; } if (!add_creature_to_work_room(thing, room)) { set_start_state(thing); return 0; } internal_set_thing_state(thing, CrSt_Scavengering); cctrl->field_82 = 0; return 1; }
short at_guard_post_room(struct Thing *thing) { struct CreatureControl *cctrl; struct Room *room; cctrl = creature_control_get_from_thing(thing); cctrl->target_room_id = 0; room = get_room_thing_is_on(thing); if (!room_initially_valid_as_type_for_thing(room, get_room_for_job(Job_GUARD), thing)) { WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(thing),(int)thing->index); set_start_state(thing); return 0; } if (!add_creature_to_work_room(thing, room, Job_GUARD)) { set_start_state(thing); return 0; } internal_set_thing_state(thing, get_continue_state_for_job(Job_GUARD)); if (!person_get_somewhere_adjacent_in_room(thing, room, &cctrl->moveto_pos)) { cctrl->moveto_pos.x.val = thing->mappos.x.val; cctrl->moveto_pos.y.val = thing->mappos.y.val; cctrl->moveto_pos.z.val = thing->mappos.z.val; } return 1; }
short at_workshop_room(struct Thing *thing) { struct CreatureControl *cctrl; struct Room *room; //return _DK_at_workshop_room(thing); cctrl = creature_control_get_from_thing(thing); cctrl->target_room_id = 0; room = get_room_thing_is_on(thing); if (!room_initially_valid_as_type_for_thing(room, RoK_WORKSHOP, thing)) { WARNLOG("Room %s owned by player %d is invalid for %s",room_code_name(room->kind),(int)room->owner,thing_model_name(thing)); set_start_state(thing); return 0; } if (room->total_capacity <= room->used_capacity) { set_start_state(thing); return 0; } if ( !add_creature_to_work_room(thing, room) ) { set_start_state(thing); return 0; } internal_set_thing_state(thing, CrSt_Manufacturing); setup_move_to_new_workshop_position(thing, room, 1); return 1; }
short at_research_room(struct Thing *thing) { struct CreatureControl *cctrl; struct Dungeon *dungeon; struct Room *room; cctrl = creature_control_get_from_thing(thing); cctrl->target_room_id = 0; dungeon = get_dungeon(thing->owner); if (!creature_can_do_research(thing)) { if (!is_neutral_thing(thing) && (dungeon->current_research_idx < 0)) { if (is_my_player_number(dungeon->owner)) output_message(SMsg_NoMoreReseach, 500, true); } set_start_state(thing); return 0; } room = get_room_thing_is_on(thing); if (!room_initially_valid_as_type_for_thing(room, RoK_LIBRARY, thing)) { WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(thing),(int)thing->index); set_start_state(thing); return 0; } if (!add_creature_to_work_room(thing, room)) { set_start_state(thing); return 0; } if (!setup_random_head_for_room(thing, room, NavRtF_Default)) { ERRORLOG("The %s index %d can not move in research room", thing_model_name(thing),(int)thing->index); remove_creature_from_work_room(thing); set_start_state(thing); return 0; } thing->continue_state = CrSt_Researching; cctrl->field_82 = 0; cctrl->byte_9A = 3; return 1; }
short at_training_room(struct Thing *thing) { struct CreatureControl *cctrl; struct CreatureStats *crstat; struct Dungeon *dungeon; struct Room *room; //return _DK_at_training_room(thing); cctrl = creature_control_get_from_thing(thing); cctrl->target_room_id = 0; if (!creature_can_be_trained(thing)) { SYNCDBG(9,"Ending training of %s level %d; creature is not trainable",thing_model_name(thing),(int)cctrl->explevel); set_start_state(thing); return 0; } crstat = creature_stats_get_from_thing(thing); dungeon = get_dungeon(thing->owner); if (dungeon->total_money_owned < crstat->training_cost) { if (is_my_player_number(thing->owner)) output_message(SMsg_NoGoldToTrain, MESSAGE_DELAY_TREASURY, true); set_start_state(thing); return 0; } room = get_room_thing_is_on(thing); if (!room_initially_valid_as_type_for_thing(room, RoK_TRAINING, thing)) { WARNLOG("Room %s owned by player %d is invalid for %s",room_code_name(room->kind),(int)room->owner,thing_model_name(thing)); set_start_state(thing); return 0; } if ( !add_creature_to_work_room(thing, room) ) { set_start_state(thing); return 0; } internal_set_thing_state(thing, CrSt_Training); setup_move_to_new_training_position(thing, room, 1); cctrl->field_82 = 0; return 1; }
short at_barrack_room(struct Thing *creatng) { struct Room *room; struct CreatureControl *cctrl; cctrl = creature_control_get_from_thing(creatng); cctrl->target_room_id = 0; room = get_room_thing_is_on(creatng); if (!room_initially_valid_as_type_for_thing(room, RoK_BARRACKS, creatng)) { WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(creatng),(int)creatng->index); set_start_state(creatng); return 0; } if (!add_creature_to_work_room(creatng, room)) { set_start_state(creatng); return 0; } internal_set_thing_state(creatng, CrSt_Barracking); return 1; }
short creature_arrived_at_prison(struct Thing *creatng) { struct CreatureControl *cctrl; struct Room *room; TRACE_THING(creatng); cctrl = creature_control_get_from_thing(creatng); cctrl->target_room_id = 0; room = get_room_thing_is_on(creatng); if (!room_initially_valid_as_type_for_thing(room, RoK_PRISON, creatng)) { WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(creatng),(int)creatng->index); set_start_state(creatng); return 0; } if (!add_creature_to_work_room(creatng, room)) { output_message_room_related_from_computer_or_player_action(room->owner, room->kind, OMsg_RoomTooSmall); cctrl->flgfield_1 &= ~CCFlg_NoCompControl; set_start_state(creatng); return 0; } cctrl->field_82 = game.play_gameturn; cctrl->flgfield_1 |= CCFlg_NoCompControl; internal_set_thing_state(creatng, CrSt_CreatureInPrison); if (creature_affected_by_spell(creatng, SplK_Speed)) { terminate_thing_spell_effect(creatng, SplK_Speed); } if (creature_affected_by_spell(creatng, SplK_Invisibility)) { terminate_thing_spell_effect(creatng, SplK_Invisibility); } if (creatng->light_id != 0) { light_delete_light(creatng->light_id); creatng->light_id = 0; } return 1; }