Disabling Airlifting for Specific Units

RetroA

Chieftain
Joined
Sep 15, 2015
Messages
25
Location
UK
Just a quick question - I would like to prevent Spaceship components from being able to be airlifted, might make the space race a little more interesting - is there anyway of doing this?
 
Something like

Code:
function OnCanStartMission(iPlayer, iUnit, iMission)
  if (iMission == GameInfoTypes.MISSION_AIRLIFT) then
    local pUnit = Players[iPlayer]:GetUnitByID(iUnit)
	
	return (GameInfo.Units[pUnit:GetUnitType()].ProjectPrereq ~= "PROJECT_APOLLO_PROGRAM")
  end
  
  return true  
end
GameEvent.CanStartMission.Add(OnCanStartMission)
 
Thanks for the quick response whoward. Had a bit a time to look into this more, I'm pretty green when it comes to LUA - is this the full script or just the basic structure? I tried it out and couldn't get it to work. From what I got from your file attribute tutorial is that the file requires an InGameUIAddin entry but not VFS=true - is that right?
 
Thanks for the quick response whoward. Had a bit a time to look into this more, I'm pretty green when it comes to LUA - is this the full script or just the basic structure? I tried it out and couldn't get it to work. From what I got from your file attribute tutorial is that the file requires an InGameUIAddin entry but not VFS=true - is that right?
It appears he had a minor typo. It ought to be
Code:
GameEvents.CanStartMission.Add(OnCanStartMission)
Missing letter 's' at the end of "GameEvents".

Otherwise it appears to be the entire needed code. You want the file setttings you have described.
 
It appears he had a minor typo.

Otherwise it appears to be the entire needed code. You want the file setttings you have described.

Thanks Lee, made the edit - the airlift option still shows up but clicking it doesn't do anything and that's fine by me. I'm going to bundle this with one other minor mod and publish but I'll be sure to credit you both.
 
Top Bottom