Jump to content

Trying to improve an ''Air to Air training'' Script


Recommended Posts

Posted

I would like a little help from the Script gurus :helpsmilie:

 

We recently used a script to have air to air training.The aircrafts are set to Immortal and they will die only if they crash to the ground.

 

The idea of the script is that it will count hits to client aircrafts in order to get them a message that they are hit and they should leave the area and RTB.

The goal is to have air to air training and let the clients RTB with their wingman without being actualy destoyed by missiles.

 

The problem is that the script is not working for hits from humans to humans. It only works when AI fighters hit a human aircraft. It works only if the aircrafts are not Immortal.

 

-- event handlers:

HitEventHandler = {};

 

-- function - event handler for aircraft:

function HitEventHandler:onEvent(event)

-- counting hits on aircrafts:

if (world.event.S_EVENT_HIT == event.id) then

local tgt = event.target

local tgtType = tgt:getTypeName()

if (tgtType == "Su-27") or (tgtType == "Su-33") or (tgtType == "F-15C") or (tgtType == "MiG-29S") or (tgtType == "Su-25") or (tgtType == "Su-25T") or (tgtType == "A-10C") then --Check if hit unit Player Controlled

local player = Unit.getPlayerName(tgt)

trigger.action.outText( player .. ' you are hit. Leave the area!' ,20)

end

end

end

 

world.addEventHandler(HitEventHandler)

 

*We added the line :

If (tgtType == "Su-27") or (tgtType == "Su-33") or (tgtType == "F-15C") or (tgtType == "MiG-29S") or (tgtType == "Su-25") or (tgtType == "Su-25T") or (tgtType == "A-10C")

cause the script crashes when an AI hits another AI. So we had only human SU-27,F-15,MIG-29,SU-25T/A in the mission and the AI's are another type of aircraft.

"ARGO" DCS UH-1H DLC SP Campaign

373vFS DCS World squadron (Greece) - www.buddyspike.net

"ARGO 2.0 Project Phoenix" UH-1H DLC Campaign - WIP

Posted

I use this code I found on the Russian part of the forum to check types. Maby this will give you an idea how to change your code ;) I also inculded a test mission.

 

-- obtaining type names: 
local _zone = trigger.misc.getZone('get_types');
local _volume = {
   id = world.VolumeType.SPHERE,
   params = {
       point = _zone.point,
       radius = _zone.radius
  }
};

local _types = { allNames = '' };

world.searchObjects(Object.Category.UNIT, _volume, function(_object, _data)
       _data.allNames = _data.allNames .. _object:getTypeName() .. '\n\r';
       return true;
   end, _types);
   
trigger.action.outText(_types.allNames, 30);

Test - Display object types.miz

 

EDIT: I have run this in both SP and MP but you get the same type on both.

Posted

I think you must go the way and identify if the target is human and then read the group or maybe the other way around. Can you serialize all active players (AI.Skill == 'CLIENT') and get their unitID?

 

AI

Contains constants used in Controller functions.

AI.Skill = {
  AVERAGE,
  GOOD,
  HIGH,
  EXCELLENT,
  PLAYER,
  CLIENT
}

Posted

Having a similar problem.

By the looks of it, world.event.S_EVENT_HIT does not register gun rounds form a client.

 

Is there a way to have it working, or an alternative ?

dUJOta.jpg

 

Windows 11 | i9 12900KF | 64GB DDR4 | RTX 3090 | TM Warthog HOTAS | Saitek Combat Rudder Pedals | TM MFDs + Lilliput 8" | TIR5 Pro

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...