long computer_check_for_expand_room(struct Computer2 *comp, struct ComputerCheck * check) { SYNCDBG(8,"Starting"); //return _DK_computer_check_for_expand_room(comp, check); struct Dungeon *dungeon; dungeon = comp->dungeon; if (dungeon_invalid(dungeon)) { ERRORLOG("Invalid computer players dungeon"); return 0; } long around_start; around_start = ACTION_RANDOM(119); // Don't work when placing rooms; we could place in an area for room by mistake if (is_task_in_progress(comp, CTT_PlaceRoom) || is_task_in_progress(comp, CTT_CheckRoomDug)) { SYNCDBG(8,"No rooms expansion - colliding task already in progress"); return 0; } if (4 * dungeon->creatures_total_pay / 3 >= dungeon->total_money_owned) { SYNCDBG(8,"No rooms expansion - we don't even have money for payday"); return 0; } const struct ExpandRooms *expndroom; for (expndroom = &expand_rooms[0]; expndroom->rkind != RoK_NONE; expndroom++) { if (computer_check_for_expand_room_kind(comp, check, expndroom->rkind, expndroom->max_slabs, around_start)) { return 1; } } SYNCDBG(8,"No rooms found for expansion"); return 0; }
long computer_check_move_creatures_to_best_room(struct Computer2 *comp, struct ComputerCheck * check) { struct Dungeon *dungeon; dungeon = comp->dungeon; SYNCDBG(8,"Starting"); //return _DK_computer_check_move_creatures_to_best_room(comp, check); //TODO check if should be changed to computer_able_to_use_magic() if (!is_power_available(dungeon->owner, PwrK_HAND)) { return 4; } int num_to_move; num_to_move = check->param1 * dungeon->num_active_creatrs / 100; if (num_to_move <= 0) { SYNCDBG(8,"No creatures to move, active %d percentage %d", (int)dungeon->num_active_creatrs, (int)check->param1); return 4; } if (is_task_in_progress(comp, CTT_MoveCreatureToRoom)) { return 4; } if (!create_task_move_creatures_to_room(comp, 0, num_to_move)) { return 4; } SYNCDBG(8,"Added task to move %d creatures to best room", (int)num_to_move); return 1; }
long computer_check_move_creatures_to_room(struct Computer2 *comp, struct ComputerCheck * check) { struct Dungeon *dungeon; struct Room *room; dungeon = comp->dungeon; SYNCDBG(8,"Checking player %d for move to %s", (int)dungeon->owner, room_code_name(check->param2)); //return _DK_computer_check_move_creatures_to_room(comp, check); //TODO check if should be changed to computer_able_to_use_magic() if (!is_power_available(dungeon->owner, PwrK_HAND)) { return 4; } int num_to_move; num_to_move = check->param1 * dungeon->num_active_creatrs / 100; if (num_to_move <= 0) { SYNCDBG(8,"No creatures to move, active %d percentage %d", (int)dungeon->num_active_creatrs, (int)check->param1); return 4; } if (is_task_in_progress(comp, CTT_MoveCreatureToRoom)) { return 4; } unsigned long k; long i; k = 0; i = dungeon->room_kind[check->param2]; while (i != 0) { room = room_get(i); if (room_is_invalid(room)) { ERRORLOG("Jump to invalid room detected"); break; } i = room->next_of_owner; // Per-room code if (room->total_capacity > room->used_capacity) { if (create_task_move_creatures_to_room(comp, room->index, num_to_move)) { SYNCDBG(8,"Added task to move %d creatures to %s index %d", (int)num_to_move,room_code_name(room->kind),(int)room->index); return 1; } } // Per-room code ends k++; if (k > ROOMS_COUNT) { ERRORLOG("Infinite loop detected when sweeping rooms list"); break; } } return 4; }
long computer_check_for_expand_room(struct Computer2 *comp, struct ComputerCheck * check) { if (is_newdig_enabled(comp)) return 4; SYNCDBG(8,"Starting"); struct Dungeon *dungeon; dungeon = comp->dungeon; if (dungeon_invalid(dungeon) || !player_has_heart(dungeon->owner)) { SYNCDBG(7,"Computer players %d dungeon in invalid or has no heart",(int)dungeon->owner); return CTaskRet_Unk4; } long around_start; around_start = ACTION_RANDOM(119); // Don't work when placing rooms; we could place in an area for room by mistake if (is_task_in_progress(comp, CTT_PlaceRoom) || is_task_in_progress(comp, CTT_CheckRoomDug)) { SYNCDBG(8,"No rooms expansion - colliding task already in progress"); return CTaskRet_Unk0; } if (computer_player_in_emergency_state(comp)) { SYNCDBG(8,"No rooms expansion - emergency state"); return CTaskRet_Unk0; } if (get_computer_money_less_cost(comp) < dungeon->creatures_total_pay / 3) { SYNCDBG(8,"No rooms expansion - not enough money buffer"); return CTaskRet_Unk0; } const struct ExpandRooms *expndroom; for (expndroom = &expand_rooms[0]; expndroom->rkind != RoK_NONE; expndroom++) { if (computer_check_for_expand_room_kind(comp, check, expndroom->rkind, expndroom->max_slabs, around_start)) { return CTaskRet_Unk1; } } SYNCDBG(8,"No rooms found for expansion"); return CTaskRet_Unk0; }
long computer_check_slap_imps(struct Computer2 *comp, struct ComputerCheck * check) { struct Dungeon *dungeon; SYNCDBG(8,"Starting"); dungeon = comp->dungeon; if (!is_power_available(dungeon->owner, PwrK_SLAP)) { return CTaskRet_Unk4; } long creatrs_num; creatrs_num = check->param1 * dungeon->num_active_diggers / 100; if (!is_task_in_progress(comp, CTT_SlapDiggers)) { if (create_task_slap_imps(comp, creatrs_num)) { return CTaskRet_Unk1; } } return CTaskRet_Unk4; }