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_best_room(struct Computer2 *comp, struct ComputerCheck * check) { struct Dungeon *dungeon; dungeon = comp->dungeon; SYNCDBG(8,"Starting for player %d",(int)dungeon->owner); int num_to_move; num_to_move = check->param1 * dungeon->num_active_creatrs / 100; if (num_to_move <= 0) { SYNCDBG(8,"No player %d creatures to move, active %d percentage %d", (int)dungeon->owner,(int)dungeon->num_active_creatrs,(int)check->param1); return CTaskRet_Unk4; } if (computer_able_to_use_magic(comp, PwrK_HAND, 1, num_to_move) != 1) { return CTaskRet_Unk4; } // If there's already task in progress which uses hand, then don't add more // content of the hand could be used by wrong task by mistake if (is_task_in_progress_using_hand(comp)) { return CTaskRet_Unk4; } if (!create_task_move_creatures_to_room(comp, 0, num_to_move)) { return CTaskRet_Unk4; } SYNCDBG(8,"Added player %d task to move %d creatures to best room",(int)dungeon->owner,(int)num_to_move); return CTaskRet_Unk1; }
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)); 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 CTaskRet_Unk4; } if (computer_able_to_use_magic(comp, PwrK_HAND, 1, num_to_move) != 1) { return CTaskRet_Unk4; } // If there's already task in progress which uses hand, then don't add more // content of the hand could be used by wrong task by mistake if (is_task_in_progress_using_hand(comp)) { return CTaskRet_Unk4; } 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) { int num_to_move_fit; num_to_move_fit = min(num_to_move, room->total_capacity - room->used_capacity); if (create_task_move_creatures_to_room(comp, room->index, num_to_move_fit)) { SYNCDBG(8,"Added task to move %d creatures to %s index %d", (int)num_to_move_fit,room_code_name(room->kind),(int)room->index); return CTaskRet_Unk1; } } // Per-room code ends k++; if (k > ROOMS_COUNT) { ERRORLOG("Infinite loop detected when sweeping rooms list"); break; } } return CTaskRet_Unk4; }
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; }