(I'm glad I had this backed up at
www.modsrus.com 
)
This tutorial will tell you how to make a grenade which bounces along the ground if it misses its original target. It is fairly straightforward, but does assume a reasonable skill of INI coding. Anyway, on to the code.... The first thing you need to do is make a new projectile object for your grenade weapon. This will basically be the same as any other projectile except in two areas - firstly, the grenade will actually have to 'die'if it misses (unlike normal projectiles which are 'destroyed'). This is done by giving it a HeightDieUpdate - normal projectiles never touch the ground unless they miss, as they aim for the centre of the target and so impact quite high above the ground. Secondly, the grenade will have to have an OCL added to it's death sequence called when it misses. This will create the second'bouncy' grenade as projectiles themselves can't bounce... Also, I gave the projectile a proper shadow so you can actually see it bouncing but this is not important. If you want to do this though, just copy the shadow code from a vehicle or structure (not fake structures though). eg.
Quote:
Behavior = PhysicsBehavior ModuleTag_05
Mass = 5
End
Behavior = HeightDieUpdate ModuleTag_06
TargetHeight = 1.0
TargetHeightIncludesStructures = No
End
; ---- begin Projectile death behaviors
Behavior = InstantDeathBehavior DeathModuleTag_01
DeathTypes = NONE +DETONATED
End
Behavior = InstantDeathBehavior DeathModuleTag_02
DeathTypes = NONE +LASERED
End
Behavior = InstantDeathBehavior DeathModuleTag_03
DeathTypes = ALL -LASERED -DETONATED
FX = FX_GrenadeBounce
OCL = OCL_CreateBouncingGrenade
End
; ---- end Projectile death behaviors
|
Right, now you've done that you need to make a new object which is unlike any other projectile in the game (as it's not technically a projectile....) This will be the object which is created when the first projectile dies and this is the one which will bounce along the ground afterwards. Firstly, the grenade needs a WanderAIUpdate. This causes it to move without having to be ordered to. The direction and speed of it moving have to be set later though (in the ObjectCreationList and the Locomotor INIs respectively) It also needs to have a LifetimeUpdate and a FireWeaponWhenDead module in order for it to actually blow up The dead weapon should be exactly the same as the normal grenade wepaon except it should have no projectile set, but more on this later...Also, the PhysicsUpadate in this object is fairly important - "AllowsBouncing = Yes" should be set. I wonder why that could be....
Quote:
Behavior = DestroyDie ModuleTag_03
;nothing
End
Behavior = LifetimeUpdate ModuleTag_04 ; random death time
MinLifetime = 1000 ; min lifetime in msec
MaxLifetime = 2000 ; max lifetime in msec
End
Behavior = PhysicsBehavior ModuleTag_05
Mass = 0.6 ; we can't have a zero mass, but we want it pretty tiny...
AllowBouncing = Yes
End
Behavior = FireWeaponWhenDeadBehavior ModuleTag_06
DeathWeapon = DiscThrowerGrenadeBounceWeapon
StartsActive = Yes
End
Behavior = WanderAIUpdate ModuleTag_07
End
Locomotor = SET_NORMAL DiscBounceLocomotor
; ---- begin Projectile death behaviors
Behavior = InstantDeathBehavior DeathModuleTag_01
DeathTypes = ALL
; we detonated normally.
FX = WeaponFX_GenericTankShellDetonation
End
; ---- end Projectile death behaviors
|
Now on to the ObjectCreationList. This is fairly straightforward. Basically, you just want to make an entry which creates your bouncing grenade. This is then called in the death behaviours of the original projectile (top). It should also have LIKE_EXISTING and INHERIT_VELOCITY set in the Dispostion so that it continues along the same path as the original grenade. I also gave it a z-axis offset, so that it would be created slightly above the original object (in order for it get 'good bounce') but you could leave this bit out if you like.
Quote:
ObjectCreationList OCL_CreateBouncingGrenade
CreateObject
ObjectNames = YourGrenadeNameHere
Offset = X:0.0 Y:0.0 Z:1.0
Count = 1
Disposition = LIKE_EXISTING INHERIT_VELOCITY
End
End
|
The Locomotor doesn't really need much work either. Basically you just want to make a locomotor which forces the bouncing grenade to have the same speed as the original projectile. Should be HOVER appearance, and having 'StickToGround = No' would be a good idea
Quote:
Locomotor DiscBounceLocomotor
Surfaces = GROUND RUBBLE
Speed = 200 ; in dist/sec
MinSpeed = 200
TurnRate = 1 ; in degrees/sec
TurnRateDamaged = 1 ; in degrees/sec
Acceleration = 100 ; in dist/(sec^2)
AccelerationDamaged = 100 ; in dist/(sec^2)
Braking = 1 ; in dist/(sec^2)
PreferredHeight = 1
ZAxisBehavior = NO_Z_MOTIVE_FORCE
Appearance = HOVER
StickToGround = No
AllowAirborneMotiveForce = Yes
End
|
Fianlly, to the weapons... This bit is very simple. The original weapon fired by the unit which you want to have the grenade weapon is just a normal weapon using your normal grenade projectile object (DiscGrenade in this case)
Quote:
Weapon DiscThrowerGrenadeWeapon
PrimaryDamage = 60.0
PrimaryDamageRadius = 5.0
ScatterRadiusVsInfantry = 10.0 ;When this weapon is used against infantry, it can randomly miss by as much as this distance.
AttackRange = 150.0
DamageType = EXPLOSION
DeathType = NORMAL
WeaponSpeed = 200 ; dist/sec
ProjectileObject = DiscGrenade
ProjectileDetonationFX =
WeaponFX_GenericTankShellDetonation
RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
DelayBetweenShots = 1500 ; time between shots, msec
ClipSize = 0 ; how many shots in a Clip (0 == infinite)
ClipReloadTime = 0 ; how long to reload a Clip, msec
ProjectileCollidesWith = STRUCTURES WALLS
End
|
The second weapon you need is the one called when the bouncing grenade reaches the end of its life. This should be the same as the original grenade weapon, except should have no Projectile settings, no scatter radius and a clip size of 1.
Quote:
Weapon DiscThrowerGrenadeBounceWeapon
PrimaryDamage = 60.0
PrimaryDamageRadius = 5.0
AttackRange = 150.0
DamageType = EXPLOSION
DeathType = NORMAL
FireSound = MarauderTankWeapon
RadiusDamageAffects = ALLIES ENEMIES NEUTRALS
DelayBetweenShots = 1500 ; time between shots, msec
ClipSize = 1 ; how many shots in a Clip (0 == infinite)
ClipReloadTime = 0 ; how long to reload a Clip, msec
End
|
Well Done! You should now have a working bouncing grenade launcher. Perfect for Tiberian Sun mods
By DJRowley
Comments/criticisms/etc are welcome
