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

Function qBeamHittingPlayer

scripts/Merc02.cpp:1111–1139  ·  view source on GitHub ↗

$$QUERY Custom b:Beam between [o:Beam Source A] and [o:Beam Source B] is hitting a player qBeamHittingPlayer Beam Is Hitting a Player Checks if a security beam is currently colliding with a player Parameters: Beam Source A Beam Source B $$END */

Source from the content-addressed store, hash-verified

1109$$END
1110*/
1111bool qBeamHittingPlayer(int beam1_handle, int beam2_handle) {
1112 // see if anything is in the way
1113 ray_info ray;
1114 int flags, fate;
1115 vector start_pos, end_pos, landing_pos;
1116 int start_room, landing_room;
1117
1118 if (!qObjExists(beam1_handle))
1119 return false;
1120 if (!qObjExists(beam2_handle))
1121 return false;
1122
1123 Obj_Value(beam1_handle, VF_GET, OBJV_V_POS, &start_pos);
1124 Obj_Value(beam1_handle, VF_GET, OBJV_I_ROOMNUM, &start_room);
1125 Obj_Value(beam2_handle, VF_GET, OBJV_V_POS, &end_pos);
1126
1127 flags = FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS | FQ_IGNORE_WEAPONS | FQ_ONLY_PLAYER_OBJ | FQ_PLAYERS_AS_SPHERE |
1128 FQ_IGNORE_WALLS;
1129 fate = FVI_RayCast(beam1_handle, &start_pos, &end_pos, start_room, 50.0f, flags, &ray);
1130 if (fate == HIT_OBJECT) {
1131 int type;
1132 Obj_Value(ray.hit_object, VF_GET, OBJV_I_TYPE, &type);
1133 if (type == OBJ_PLAYER) {
1134 return true;
1135 }
1136 }
1137
1138 return false;
1139}
1140
1141/*
1142$$QUERY

Callers 1

CallEventMethod · 0.70

Calls 2

qObjExistsFunction · 0.85
Obj_ValueFunction · 0.85

Tested by

no test coverage detected