| 7979 | } |
| 7980 | |
| 7981 | void BarnSwallow::ComputeNest(int me) { |
| 7982 | memory->num_friends = 0; |
| 7983 | int scan_objs[100]; |
| 7984 | int n_scan; |
| 7985 | int i; |
| 7986 | vector pos; |
| 7987 | int room; |
| 7988 | int type; |
| 7989 | uint16_t id; |
| 7990 | |
| 7991 | memory->num_friends = 0; |
| 7992 | |
| 7993 | for (i = 0; i < BS_MAX_FRIENDS; i++) |
| 7994 | memory->friends[i] = OBJECT_HANDLE_NONE; |
| 7995 | |
| 7996 | Obj_Value(me, VF_GET, OBJV_V_POS, &pos); |
| 7997 | Obj_Value(me, VF_GET, OBJV_I_ROOMNUM, &room); |
| 7998 | Obj_Value(me, VF_GET, OBJV_I_TYPE, &type); |
| 7999 | Obj_Value(me, VF_GET, OBJV_US_ID, &id); |
| 8000 | |
| 8001 | memory->home_room = room; |
| 8002 | memory->nest_center = |
| 8003 | pos; // Each robot will have a different center point becuase thier initial positions are weighted twice |
| 8004 | memory->nest_rad = 0.0f; |
| 8005 | |
| 8006 | n_scan = AI_GetNearbyObjs(&pos, room, 1000.0f, scan_objs, 100, false, true, false, true); |
| 8007 | |
| 8008 | for (i = 0; i < n_scan; i++) { |
| 8009 | if (scan_objs[i] != me) { |
| 8010 | int c_type; |
| 8011 | uint16_t c_id; |
| 8012 | Obj_Value(scan_objs[i], VF_GET, OBJV_I_TYPE, &c_type); |
| 8013 | Obj_Value(scan_objs[i], VF_GET, OBJV_US_ID, &c_id); |
| 8014 | |
| 8015 | // See if we are the same species |
| 8016 | if (type == c_type && id == c_id) { |
| 8017 | vector c_pos; |
| 8018 | Obj_Value(scan_objs[i], VF_GET, OBJV_V_POS, &c_pos); |
| 8019 | |
| 8020 | memory->nest_center += c_pos; |
| 8021 | |
| 8022 | memory->friends[memory->num_friends++] = scan_objs[i]; |
| 8023 | } |
| 8024 | } |
| 8025 | } |
| 8026 | |
| 8027 | if (memory->num_friends) |
| 8028 | memory->nest_center /= memory->num_friends + 1; |
| 8029 | |
| 8030 | // Determine the farthest distance from the center of the nest |
| 8031 | for (i = 0; i < memory->num_friends; i++) { |
| 8032 | vector c_pos; |
| 8033 | float dist; |
| 8034 | Obj_Value(memory->friends[i], VF_GET, OBJV_V_POS, &c_pos); |
| 8035 | dist = vm_VectorDistance(&memory->nest_center, &c_pos); |
| 8036 | |
| 8037 | if (dist * 0.9f > memory->nest_rad) |
| 8038 | memory->nest_rad = dist * 0.9f; |
nothing calls this directly
no test coverage detected