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

Function aKillBotsNearObj

scripts/Merc4.cpp:856–908  ·  view source on GitHub ↗

$$ACTION Custom Kill robots and players near [o:Object] aKillBotsNearObj Kill robots and players near object Kills robots and players near an object Parameters: Object: the object to search from $$END */

Source from the content-addressed store, hash-verified

854$$END
855*/
856void aKillBotsNearObj(int objhandle) {
857 int room;
858 vector pos;
859 float radius;
860 int type;
861 int scan_objs[MAX_SCAN_OBJECTS];
862 int n_scan;
863 int n, i;
864 uint16_t id;
865
866 if (!qObjExists(objhandle))
867 return;
868
869 // Look up names if we haven't already
870 if (!names_looked_up) {
871 guidebot_id = Obj_FindID("GuideBot");
872 names_looked_up = true;
873 }
874
875 // Make sure this object still exists
876 Obj_Value(objhandle, VF_GET, OBJV_I_TYPE, &type);
877 if (type == OBJ_NONE)
878 return;
879
880 // Get the size and position of the object
881 Obj_Value(objhandle, VF_GET, OBJV_F_SIZE, &radius);
882 Obj_Value(objhandle, VF_GET, OBJV_V_POS, &pos);
883 Obj_Value(objhandle, VF_GET, OBJV_I_ROOMNUM, &room);
884
885 // Scan for any nearby objects
886 // NOTE: check the func below to see what other params do!!!
887 n_scan = AI_GetNearbyObjs(&pos, room, radius, scan_objs, MAX_SCAN_OBJECTS, false, true, false, true);
888
889 // Go through the objects that have been found and kill any robots or players
890 for (i = 0; i < n_scan; i++) {
891 Obj_Value(scan_objs[i], VF_GET, OBJV_I_TYPE, &type);
892 if (type == OBJ_ROBOT || type == OBJ_PLAYER) {
893 // Make sure it's not the guidebot
894 if (type == OBJ_ROBOT) {
895 Obj_Value(scan_objs[i], VF_GET, OBJV_US_ID, &id);
896 if (id == ROBOT_GUIDEBOT || id == ROBOT_GUIDEBOTRED)
897 continue;
898 }
899
900 // Just do damage to players, but destroy robots on contact
901 if (type == OBJ_PLAYER) {
902 aObjApplyDamage(scan_objs[i], 5.0f);
903 } else {
904 aObjDestroy(scan_objs[i]);
905 }
906 }
907 }
908}
909
910int teleport_effect_id = -1;
911

Callers 1

CallEventMethod · 0.85

Calls 5

qObjExistsFunction · 0.85
Obj_ValueFunction · 0.85
AI_GetNearbyObjsFunction · 0.85
aObjApplyDamageFunction · 0.85
aObjDestroyFunction · 0.85

Tested by

no test coverage detected