Menu:

GenDev
 
  » News
  » Forums
  » Downloads
  » Link Us
  » The Team

Cameo Mapper
 
  » About
  » How to Use
  » Download

Tutorials
 
  » Modding
  » Graphics
  » Mapping

Modding Resources
 
  » GenDev Utilities
  » User Submitted Models
  » Alpha/Beta Models
  » Tutorial Downloads
  » Modding Utilities

Affiliates
 
  » CNC DEN
  » SDI
  » Defcon
  » PPM
  » BattleTech Mod
  » CNC Unleashed
  » Deezire Online
  » Sleipnir's Stuff
  » Blitzkrieg 2: The Finest Hour
  » Call To Arms

Staff Only
 
  » News Post
  » File Admin
  » File Team

Making Pilots Bail

By: Andrew

This is a current feature in my mod, Crime Lords, in which you can press a button on the command bar, and the pilot will leave the vehicle, unmanned, allowing someone else or himself to take it over later. This is a useful feature if you want to transfer veterancy, have the driver escape before a vehicle is destroyed, or other strategic actions. In order to make this work, two things must happen. First, a pilot is created and second, the driver inside the vehicle is killed. Making the press of one button cause two different actions is difficult, and the only way I saw around it was to spawn two objects, the driver and a dummy object that blows itself up and has the death weapon that kills the driver of the vehicle. This is nearly flawless; the only inaccuracy is that when a non-pilot unit takes the wheel, a pilot still comes out, but this is a small problem and I see no way around it.

Step 1:

First thing to do is get the bail button created, so create an entry like this inside the CommandButton.ini file:

CommandButton Command_Bail
Command = OBJECT_UPGRADE
Upgrade = Upgrade_VehicleBail
Options = OK_FOR_MULTI_SELECT NOT_QUEUEABLE
TextLabel = CONTROLBAR:VehicleBail
ButtonImage = SABail
ButtonBorderType = ACTION
DescriptLabel = CONTROLBAR:ToolTipVehicleBail
End

You can change nearly anything above that you wish except that command must be an Object_Upgrade (Player_Upgrade would probably make every vehicle to bail at once when pressed).

Next, add the new button to the units you wish to have this ability inside CommandSet.ini.

Step 2:

After that, open Upgrade.ini and add this entry:

Upgrade Upgrade_VehicleBail
DisplayName = UPGRADE:None
Type = OBJECT
BuildTime = 0
BuildCost = 0
ButtonImage = SABail
ResearchSound = NoNoise
End

Under normal circumstances, when the upgrade would be “purchased,” the EVA would announce its completion and display the text saying so. This does not make sense when you bail from a car, so these must be overridden. The only way to do this is to create a blank sound to be played when it is completed. So inside SoundEffects.ini place this entry:

AudioEvent NoNoise
Sounds = addmho1c
Priority = low
Volume = 0
Limit = 0
MinRange = 0
MaxRange = 0
Type = shrouded
End

In order to stop the text from appearing, you must create a string called: UPGRADE:None that is empty. However, this does not fix the entire problem. “Upgrade Complete: ” would still appear, so you must edit that string (UPGRADE:upgradecomplete) to:
%s
However, now “Upgrade Complete: ” will not appear for other upgrades so you must now edit all other upgrades and add it to the front of there’s.

Step 3:

Now, open FactionUnit.ini and go paste the following code on every unit you wish to have the bail feature:

Behavior = ObjectCreationUpgrade ModuleTag_13
UpgradeObject = OCL_PilotBail
TriggeredBy = Upgrade_VehicleBail
End

Behavior = ObjectCreationUpgrade ModuleTag_14
UpgradeObject = OCL_VehicleBailer
TriggeredBy = Upgrade_VehicleBail
End

Behavior = ProductionUpdate ModuleTag_15
MaxQueueEntries = 1; So you can't build multiple upgrades in the same frame
End

Adjust the module tags so that they do not interfere with other tags. The first part creates the pilot, the second the dummy unit that kills the driver, and the last prevents you from hitting the button more then once and possibly creating more then one pilot before the vehicle is empty.

Next, open ObjectCreationList.ini and add these lines:

ObjectCreationList OCL_PilotBail
CreateObject
Offset = X:5 Y:10 Z:0
ObjectNames = AmericaInfantryPilot
InheritsVeterancy = Yes
IgnorePrimaryObstacle = Yes
Disposition = LIKE_EXISTING
Count = 1
RequiresLivePlayer = No
End
End
ObjectCreationList OCL_VehicleBailer
CreateObject
Offset = X:0 Y:0 Z:0
ObjectNames = VehicleBailer
IgnorePrimaryObstacle = Yes
Disposition = LIKE_EXISTING
Count = 1
RequiresLivePlayer = No
End
End

The “InheritsVeterancy” line will allow the pilot to keep the veterancy of the vehicle. You can edit what you want the pilot to be, however you will need to add some veterancy lines that are already there for the pilot.

Step 4:

Now reopen Faction.ini and add this entry for the vehicle bailer:

Object VehicleBailer

; ***DESIGN parameters *** DisplayName = OBJECT:Bailer
Side = China
EditorSorting = VEHICLE
ArmorSet
Armor = TruckArmor
End
VisionRange = 1
ShroudClearingRange = 0

; *** ENGINEERING Parameters ***
KindOf = CAN_ATTACK PROJECTILE
RadarPriority = LOCAL_UNIT_ONLY

Body = ActiveBody ModuleTag_02
MaxHealth = 10.0
InitialHealth = 10.0
End

Behavior = DestroyDie ModuleTag_03
DeathTypes = ALL
End

Behavior = AIUpdateInterface ModuleTag_09
End
Behavior = PhysicsBehavior ModuleTag_10
Mass = 1.0
End

Behavior = FireWeaponWhenDeadBehavior ModuleTag_22
DeathWeapon = CarBail
StartsActive = Yes
DeathTypes = ALL
End

Behavior = LifetimeUpdate ModuleTag_23
MinLifetime = 0 ; min lifetime in msec
MaxLifetime = 0 ; max lifetime in msec
End

Behavior = UpgradeDie ModuleTag_24
DeathTypes = ALL
UpgradeToRemove = Upgrade_VehicleBail ModuleTag_25
End

Geometry = BOX
GeometryIsSmall = Yes
GeometryMajorRadius = 11.0
GeometryMinorRadius = 4.0
GeometryHeight = 7.0
Shadow = SHADOW_VOLUME

End

The key parts of this entry are KindOf = PROJECTILE which prevents the object from being announced when killed, the FireWeaponWhenDeadBehavior which causes the weapon to be fired, LifetimeUpdate which makes the unit die, and UpgradeDie which makes it remove the upgrade you purchased so that you will be able to bail again after you recapture the vehicle.

The last thing you must do now is create the weapon the dummy unit uses.
Inside Weapon.ini add:

Weapon CarBail
PrimaryDamage = 0.0
PrimaryDamageRadius = 0.1
DamageType = KILL_PILOT
DeathType = NORMAL
WeaponSpeed = 99999.0
AttackRange = 5.0
ProjectileObject = NONE
DamageDealtAtSelfPosition = Yes
RadiusDamageAffects = SELF SUICIDE ALLIES
DelayBetweenShots = 0
ClipSize = 1
ClipReloadTime = 0
AutoReloadsClip = Yes
End

After you have completed all these steps, it should be complete. Contact me if there are any problems or questions.

Layout by Origin-Network