TOWED ARTILLERY
As promised, here is the detailed explanation on how to make towable artillery:
The system uses the RIDERS logic with an object that is actually the gun.
The whole trick is to store the truck into the gun and give the gun a different look so it looks and feels like a towingvehicle+gun.
The advantage is that you can differentiate locomotor, weapon, commandset and set a specific towing unit that is able to only tow this type of gun.
What do you need before starting to code?
-an empty chassis model with the gun as turret
-a model of a truck or towing vehicle
-a model with the 2 combined, specially setup as a trailer/cab (see on the CVtanker on how to do that)
the code :
1) guntemplate
In the riderchangecontain module, you only need 2 riderslots to make this working:
Code:
Behavior = RiderChangeContain ModuleTag_56
Rider1 = RidersDummy RIDER1 WEAPON_RIDER1 STATUS_RIDER1 GunCommandSet1 SET_SLUGGISH
Rider2 = VehicleTransport RIDER2 WEAPON_RIDER2 STATUS_RIDER2 GunCommandSet2 SET_NORMAL
ScuttleDelay = 5000
ScuttleStatus = TOPPLED
Slots = 1
InitialPayload = VehicleTransport 1
ScatterNearbyOnExit = No
HealthRegen%PerSec = 0
DamagePercentToUnits = 100%
BurnedDeathToUnits = No
AllowInsideKindOf = VEHICLE
ExitDelay = 250
NumberOfExitPaths = 1
GoAggressiveOnExit = Yes
End
a ) As the towed gun comes out of the factory towed by a vehicle, you need to load it up with the initial vehicle (VehicleTransport) inside.
InitialPayload = VehicleTransport 1
b ) Only allow 1 vehicle at the time and although a bit redundant allow only VEHICLES to enter the unit.
c ) When the gun is being towed, we can't have the unit shoot at other units, so you'll need to set WEAPON_RIDER2 so that it isn't able to target any enemy unit.
Code:
WeaponSet
Conditions = WEAPON_RIDER2
Weapon = PRIMARY none
End
d ) For the WEAPON_RIDER1 you can use any normal weapon you wish.
e ) You can change the commandset for the detached or towed gun, so you can differ in commands when driving around or preparing to fire.
f ) Using the rider logic you can also define different locomotors. If you make a locomotor with speed =0 then can make an immovable gun that can turn in place , because it is a turret.
2) ridersdummy
When you use the normal evacuation button with the riders logic, your unit becomes uncontrollable and destroys it self after the time given by "Scuttledelay="
To solve this problem we have to fall back to an OCL.
By using an OCL, we can use a specific tag, used with the overlord, which allows a dummy unit to be created inside our container.
Code:
ObjectCreationList OCL_DitchRider
CreateObject
ObjectNames = RidersDummy
Count = 1
ContainInsideSourceObject = Yes
End
End
The problem now is how are we going to bring it into the interface?
Although you can probably do it with an upgrade also, I found Sleipnir's method more elegant then mine, as it save the use of upgrades for other stuff, and uses a special power instead.
So below the riderchangecontainer module of your gun unit, you also need to insert this:
Code:
Behavior = OCLSpecialPower ModuleTag_DitchRider
SpecialPowerTemplate = SpecialAbilityCombatBikeDitchRider
OCL = OCL_DitchRider
End
As you see we're using a special power to initiate the OCL.
You then need to add this entry as special power on the specialpower.ini, using one of the unused enum's :
Code:
SpecialPower SpecialAbilityCombatBikeDitchRider
Enum = SPECIAL_CIA_INTELLIGENCE
ReloadTime = 0 ; in milliseconds
PublicTimer = No
End
To have an interface to this special power we'll trick the user in believing he's evacuating, where in reality he's using a special power:
Code:
CommandButton Command_ForceDummy
Command = SPECIAL_POWER
SpecialPower = SpecialAbilityCombatBikeDitchRider
Options = NEED_SPECIAL_POWER_SCIENCE OK_FOR_MULTI_SELECT MUST_BE_STOPPED
TextLabel = CONTROLBAR:Evacuate
ButtonImage = SSEvacButton
ButtonBorderType = SYSTEM
DescriptLabel = CONTROLBAR:ToolTipEvacuate
End
As you can see, we use the SSEvacButton to disguise the creation of an OCL.
The end user believes he's emptying the unit, where in reality he creates a new unit inside the container, effectively pushing the original unit out of the container.
So, the truck comes out of the container, forced out by the dummy, yet when you reorder the truck into the gun, the dummy gets forced out, leaving it onto the map.
After a while your map may hold a lot of these orphaned dummy’s. We solve this as follow:
Code:
;------------------------------------------------------------------------------
Object RidersDummy
EditorSorting = VEHICLE
TransportSlotCount = 1
KindOf = PRELOAD VEHICLE CLICK_THROUGH NO_SELECT
Body = ActiveBody ModuleTag_02
MaxHealth = 1
InitialHealth = 1
End
Behavior = AIUpdateInterface ModuleTag_03
End
; Behavior = LifetimeUpdate ModuleTag_04
; MinLifetime = 1
; MaxLifetime = 1
; End
Behavior = DeletionUpdate ModuleTag_05; Not LifetimeUpdate, since I can't die. This will DestroyObject me.
MinLifetime = 1
MaxLifetime = 1
End
End
As you see, we're using the deletionupdate and not the lifetimeupdate. The difference is that with a liftime update the "unit lost" voice is triggered, where as with the deletionupdate it magically disappears.
The nice thing about this is that the deletion only starts working, the moment the unit leaves the container. Hence it doesn't interfere with the proper working of our 100% working towed guns!!!
As extra, I can confirm that you can use a fully, with infantry loaded, truck and store it into the container and get it with all infantry intact out again.
As bonus
I'd like to add a variation of this,
made by Sleipnir,
that exploits the use of different locomotors, effectively allowing you to switch locomotors on the fly and on command !
Code:
WhateverUnit.ini
Code:
; In your Unit
Locomotor = SET_NORMAL NormalLocomotor
Locomotor = SET_SLUGGISH SlowLocomotor
Locomotor = SET_SUPERSONIC FastLocomotor
Behavior = RiderChangeContain ModuleTag_16
Rider1 = LocomotorDummy1 RIDER1 WEAPON_RIDER1 STATUS_RIDER1 DefaultCommandSet SET_NORMAL
Rider2 = LocomotorDummy2 RIDER2 WEAPON_RIDER2 STATUS_RIDER2 DefaultCommandSet SET_SUPERSONIC
Rider3 = LocomotorDummy3 RIDER3 WEAPON_RIDER3 STATUS_RIDER3 DefaultCommandSet SET_SLUGGISH
ScuttleDelay = 150000
ScuttleStatus = TOPPLED
Slots = 1
InitialPayload = LocomotorDummy1 1
ScatterNearbyOnExit = No
HealthRegen%PerSec = 0
DamagePercentToUnits = 100%
BurnedDeathToUnits = No
AllowInsideKindOf = INFANTRY
ExitDelay = 0
NumberOfExitPaths = 1
GoAggressiveOnExit = No
DoorOpenTime = 0
End
Behavior = OCLSpecialPower ModuleTag_SwitchLocomotor1 SpecialPowerTemplate = SpecialAbilitySwitchtoLocomotor1
OCL = OCL_SwitchLocomotor1
End
Behavior = OCLSpecialPower ModuleTag_SwitchLocomotor2 SpecialPowerTemplate = SpecialAbilitySwitchtoLocomotor2
OCL = OCL_SwitchLocomotor2
End
Behavior = OCLSpecialPower ModuleTag_SwitchLocomotor3 SpecialPowerTemplate = SpecialAbilitySwitchtoLocomotor3
OCL = OCL_SwitchLocomotor3
End
;where X is 1 2 or 3
Object LocomotorDummyX
Side = GLA
TransportSlotCount = 1
EditorSorting = SYSTEM
KindOf = PRELOAD CLICK_THROUGH INFANTRY IGNORED_IN_GUI
End
Commandbutton.ini
;where X is 1 2 or 3
CommandButton Command_SwitchtoLocomotorX
Command = SPECIAL_POWER
SpecialPower = SpecialAbilitySwitchtoLocomotorX
Options = NEED_SPECIAL_POWER_SCIENCE OK_FOR_MULTI_SELECT MUST_BE_STOPPED
TextLabel =
ButtonImage =
ButtonBorderType = SYSTEM
DescriptLabel =
End
Specialpower.ini
Code:
;where X is 1 2 or 3
SpecialPower SpecialAbilitySwitchtoLocomotorX
Enum = SPECIAL_CIA_INTELLIGENCE
ReloadTime = 0; in milliseconds
PublicTimer = No
End
Objectcreationlist.ini
Code:
;where X is 1 2 or 3
ObjectCreationList OCL_SwitchtoLocomotorX
CreateObject
ObjectNames = LocomotorDummyX
Count = 1
ContainInsideSourceObject = Yes
End
End
Please respect the copyrights on this and the variation upon it.
That's all I ask. For the rest, it is free to use for everyone.