MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ObjectsAreRelated

Function ObjectsAreRelated

Descent3/WeaponFire.cpp:965–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

963}
964
965bool ObjectsAreRelated(int o1, int o2) {
966 if ((o1 < 0) || (o2 < 0))
967 return false;
968
969 const object *obj1 = &Objects[o1];
970 const object *obj2 = &Objects[o2];
971
972 ASSERT(obj1->handle != OBJECT_HANDLE_NONE);
973 ASSERT(obj2->handle != OBJECT_HANDLE_NONE);
974
975 if (obj1->movement_type == MT_OBJ_LINKED || obj2->movement_type == MT_OBJ_LINKED)
976 return true;
977
978 if (obj1->type != OBJ_SHOCKWAVE && (obj1->mtype.phys_info.flags & PF_NO_COLLIDE)) {
979 return true;
980 }
981
982 if (obj2->type != OBJ_SHOCKWAVE && (obj2->mtype.phys_info.flags & PF_NO_COLLIDE)) {
983 return true;
984 }
985
986 if (((obj1->type == OBJ_PLAYER) && ((obj2->type == OBJ_ROBOT) && (obj2->id == GENOBJ_CHAFFCHUNK))) ||
987 ((obj2->type == OBJ_PLAYER) && ((obj1->type == OBJ_ROBOT) && (obj1->id == GENOBJ_CHAFFCHUNK))))
988 return true;
989
990 if (((obj1->type == OBJ_BUILDING) && (obj1->movement_type != MT_NONE) && (obj2->type == OBJ_POWERUP)) ||
991 ((obj2->type == OBJ_BUILDING) && (obj2->movement_type != MT_NONE) && (obj1->type == OBJ_POWERUP))) {
992 return true;
993 }
994
995 if (obj1->type == OBJ_DOOR && DoorwayGetPosition(&Rooms[obj1->roomnum]) == 1.0f && obj2->type == OBJ_ROBOT)
996 return true;
997
998 if (obj2->type == OBJ_DOOR && DoorwayGetPosition(&Rooms[obj2->roomnum]) == 1.0f && obj1->type == OBJ_ROBOT)
999 return true;
1000
1001 if (AreObjectsAttached(obj1, obj2))
1002 return true;
1003
1004 if (obj1->type != OBJ_WEAPON && obj2->type != OBJ_WEAPON) {
1005 if (((Gametime < obj1->creation_time + 3.0f) && obj1->parent_handle == obj2->handle) ||
1006 ((Gametime < obj2->creation_time + 3.0f) && obj2->parent_handle == obj1->handle))
1007 return true;
1008 else
1009 return false;
1010 }
1011
1012 if (obj1->type == OBJ_WEAPON && obj1->movement_type == MT_PHYSICS && (obj1->mtype.phys_info.flags & PF_PERSISTENT) &&
1013 obj1->ctype.laser_info.last_hit_handle == obj2->handle)
1014 return true;
1015
1016 if (obj2->type == OBJ_WEAPON && obj2->movement_type == MT_PHYSICS && (obj2->mtype.phys_info.flags & PF_PERSISTENT) &&
1017 obj2->ctype.laser_info.last_hit_handle == obj1->handle)
1018 return true;
1019
1020 // See if o2 is the parent of o1
1021 if (obj1->type == OBJ_WEAPON && (obj1->mtype.phys_info.flags & PF_NO_COLLIDE_PARENT)) {
1022 if (obj1->parent_handle == obj2->handle)

Callers 6

check_hit_objFunction · 0.85
AIDoTrackFrameFunction · 0.85
ai_moveFunction · 0.85
AIObjFriendFunction · 0.85
AIObjEnemyFunction · 0.85
AquireElectricalTargetFunction · 0.85

Calls 2

AreObjectsAttachedFunction · 0.85
ObjGetFunction · 0.85

Tested by

no test coverage detected