TbBool find_pressure_trigger_trap_target_passing_by_subtile(const struct Thing *traptng, MapSubtlCoord stl_x, MapSubtlCoord stl_y, struct Thing **found_thing) { struct Thing *thing; struct Map *mapblk; long i; unsigned long k; mapblk = get_map_block_at(stl_x,stl_y); k = 0; i = get_mapwho_thing_index(mapblk); while (i != 0) { thing = thing_get(i); TRACE_THING(thing); if (thing_is_invalid(thing)) { ERRORLOG("Jump to invalid thing detected"); break; } i = thing->next_on_mapblk; // Per thing code start if (thing_is_creature(thing) && (thing->owner != traptng->owner)) { if (!creature_is_being_unconscious(thing) && !thing_is_dragged_or_pulled(thing) && !creature_is_kept_in_custody_by_enemy(thing) && !creature_is_dying(thing) && ((get_creature_model_flags(thing) & CMF_IsSpectator) == 0)) { if (!is_neutral_thing(thing) && !players_are_mutual_allies(traptng->owner,thing->owner)) { *found_thing = thing; return true; } } } // Per thing code end k++; if (k > THINGS_COUNT) { ERRORLOG("Infinite loop detected when sweeping things list"); break; } } return false; }
long computer_check_enemy_entrances(struct Computer2 *comp, struct ComputerCheck * check) { SYNCDBG(8,"Starting"); //return _DK_computer_check_enemy_entrances(comp, check); long result; result = 4; PlayerNumber plyr_idx; for (plyr_idx=0; plyr_idx < PLAYERS_COUNT; plyr_idx++) { if (comp->dungeon->owner == plyr_idx) { continue; } if (players_are_mutual_allies(comp->dungeon->owner, plyr_idx)) { continue; } struct PlayerInfo *player; struct Dungeon *dungeon; player = get_player(plyr_idx); dungeon = get_players_dungeon(player); long i; unsigned long k; i = dungeon->room_kind[RoK_ENTRANCE]; k = 0; while (i != 0) { struct Room *room; room = room_get(i); if (room_is_invalid(room)) { ERRORLOG("Jump to invalid room detected"); break; } i = room->next_of_owner; // Per-room code struct Comp2_UnkStr1 *unkptr; unkptr = &comp->unkarr_A10[(int)plyr_idx]; long n; for (n = 0; n < 64; n++) { struct Coord3d *pos; pos = &unkptr->pos_A[n]; if ((pos->x.val == subtile_coord(room->central_stl_x,0)) && (pos->y.val == subtile_coord(room->central_stl_y,0))) { break; } } if (n == 64) { struct Coord3d *pos; n = unkptr->field_4; unkptr->field_4 = (n + 1) % 64; unkptr->field_0 = game.play_gameturn; pos = &unkptr->pos_A[n]; pos->x.val = subtile_coord(room->central_stl_x,0); pos->y.val = subtile_coord(room->central_stl_y,0); pos->z.val = subtile_coord(1,0); result = 2; } // Per-room code ends k++; if (k > ROOMS_COUNT) { ERRORLOG("Infinite loop detected when sweeping rooms list"); break; } } } return result; }
long computer_checks_hates(struct Computer2 *comp, struct ComputerCheck * check) { struct Dungeon *compdngn; SYNCDBG(8,"Starting"); //return _DK_computer_checks_hates(comp, check); compdngn = comp->dungeon; // Reference values for checking hate int cdngn_creatrs, cdngn_spdiggrs, cdngn_enrancs; cdngn_creatrs = count_creatures_in_dungeon(compdngn); cdngn_spdiggrs = count_diggers_in_dungeon(compdngn); cdngn_enrancs = count_entrances(comp, compdngn->owner); // Now check hate for every player int i; for (i=0; i < PLAYERS_COUNT; i++) { struct PlayerInfo *player; struct Dungeon *dungeon; struct Comp2_UnkStr1 *rel; player = get_player(i); dungeon = get_players_dungeon(player); rel = &comp->unkarr_A10[i]; if (!player_exists(player) || (player->id_number == compdngn->owner) || (player->id_number == game.neutral_player_num)) continue; if (player->field_2C != 1) continue; if (players_are_mutual_allies(compdngn->owner, i)) continue; int hdngn_creatrs, hdngn_spdiggrs, hdngn_enrancs; int hate_reasons; hate_reasons = 0; hdngn_creatrs = count_creatures_in_dungeon(dungeon); hdngn_spdiggrs = count_diggers_in_dungeon(dungeon); // Computers hate players who have more creatures than them if (hdngn_creatrs >= cdngn_creatrs) { hate_reasons++; rel->hate_amount++; } // Computers hate players who have more special diggers than them if (cdngn_spdiggrs / 6 + cdngn_spdiggrs < hdngn_spdiggrs) { hate_reasons++; rel->hate_amount++; } // Computers hate players who can build more rooms than them if (((int)compdngn->total_rooms + (int)compdngn->total_rooms / 6) < (int)dungeon->total_rooms) { hate_reasons++; rel->hate_amount++; } // Computers highly hate players who claimed more entrances than them hdngn_enrancs = count_entrances(comp, i); if (hdngn_enrancs > cdngn_enrancs) { hate_reasons++; rel->hate_amount += 5; } // If no reason to hate the player - hate him randomly for just surviving that long if ((hate_reasons <= 0) && (check->param1 < game.play_gameturn)) { if (ACTION_RANDOM(100) < 20) { rel->hate_amount++; } } } return 4; }