Tank Destroyer
10 years ago
So I was trying to make a weapon but encountered an annoying problem...
What It was supposed to do:
When the weapon is used it will fire a scud missile, then after a second the scud missile will disappear then 6 mini-missiles will spawn and rain down on the area.

What happened:
The missile fires, then after that the mini-missiles don't even spawn 😞
Code:

;ObjectCreationList.ini
ObjectCreationList OCL_ScatterMissiles
  DeliverPayload
    Transport                       = AWATD_DeliveryUnit
    FormationSize                   = 6
    FormationSpacing                = 1.0
    StartAtPreferredHeight          = Yes
    StartAtMaxSpeed                 = Yes
    MaxAttempts                     = 1                   ;max attempts
    DeliveryDistance                = 250                 ;distance from target allowed to start/stop dropping.
    WeaponErrorRadius               = 250                 ; how bad the artillerist is
    DelayDeliveryMax                = 1000                ; his delayed reaction to "Fire!"
    VisibleItemsDroppedPerInterval  = 5                   ;Drops two bombs at a time
    VisibleDropBoneBaseName         = RootTransform       ;The bombs are created and dropped at this bone base
    VisibleSubObjectBaseName        = Bomb                ;The bombs are visible until dropped.
    VisibleNumBones                 = 1                   ;Number of bones.
    VisiblePayloadTemplateName      = ScatterMissile  ;Created when payload is dropped.
    VisiblePayloadWeaponTemplate    = ScatterMissileWeapon
    InheritTransportVelocity        = Yes                 ;The bombs will start at transport velocity.
    ExitPitchRate                   = 30                  ;The bomb will pitch down.
    SelfDestructObject              = Yes                 ; so the delivery vehicle goes away 'POP!'
    DeliveryDecalRadius = 125
    DeliveryDecal
      Texture           = SCCArtilleryBarrage_China
      Style             = SHADOW_ALPHA_DECAL
      OpacityMin        = 25%
      OpacityMax        = 50%
      OpacityThrobTime  = 500
      Color             = R:255 G:156 B:0 A:255 
      OnlyVisibleToOwningPlayer = Yes
    End
  End
End
;WeaponObjects.ini
Object ScatterMissile_Main

  ; *** ART Parameters ***
  Draw               = W3DModelDraw ModuleTag_01
    OkToChangeModelColor = Yes
    DefaultConditionState
      Model          = UBScudStrm_M
    End
    ConditionState   = DAMAGED REALLYDAMAGED RUBBLE
      Model          = NONE
    End
    
  End

  ; ***DESIGN parameters ***
  KindOf = PROJECTILE BALLISTIC_MISSILE
  EditorSorting       = SYSTEM
  VisionRange         = 300.0  
  ShroudClearingRange = 0
  TransportSlotCount  = 10
  ArmorSet
    Conditions       = None
    Armor            = ProjectileArmor
    DamageFX         = None
  End

  ; *** AUDIO Parameters ***
  ; SoundFallingFromPlane = DaisyCutterWeapon
    
  ; *** ENGINEERING Parameters ***
  Body = ActiveBody ModuleTag_02
    MaxHealth        = 10000.0
    InitialHealth    = 10000.0
  End

  Behavior =  PhysicsBehavior ModuleTag_03
    Mass = 500.0
  End

  Behavior = MissileAIUpdate ModuleTag_04
    TryToFollowTarget             = No 
    FuelLifetime                  = 0 ; zero is infinite
    InitialVelocity               = 0                ; in dist/sec
    IgnitionFX                    = FX_ScudStormIgnition
    DistanceToTravelBeforeTurning = 500
    DistanceToTargetBeforeDiving  = 200 ; When I hit this close to target, I ignore PreferredHeight.
  End
  
  Behavior = LifetimeUpdate SplitMissile
    MinLifetime = 1000
	MaxLifetime = 1000
  End
	
  Behavior = InstantDeathBehavior ReleaseMissiles
    DeathTypes = ALL -LASERED
	OCL        = OCL_ScatterMissiles
  End

  Locomotor = SET_NORMAL SCUDStormMissileLocomotor

  Behavior = HeightDieUpdate ModuleTag_05
    TargetHeight                    = 15.0
    TargetHeightIncludesStructures  = No
    OnlyWhenMovingDown              = Yes
    SnapToGroundOnDeath             = Yes
    InitialDelay                    = 1000 ; Can't explode in the first second so we don't explode on the pad
  End

  Behavior = DestroyDie ModuleTag_06
    ;nothing
  End
  
  Geometry = Cylinder
  GeometryIsSmall = Yes
  GeometryMajorRadius = 7.0
  GeometryHeight = 30.0
End

Object ScatterMissile

  ; *** ART Parameters ***
  Draw = W3DModelDraw ModuleTag_01
    OkToChangeModelColor = Yes
    DefaultConditionState
      Model = ExMsslTm
    End
    ConditionState = JAMMED
      ParticleSysBone = None SparksMedium
    End
  End

  ; ***DESIGN parameters ***
  DisplayName      = OBJECT:RangerTeamMissile
  EditorSorting   = SYSTEM
  VisionRange = 0.0  
  ArmorSet
    Conditions      = None
    Armor           = ProjectileArmor
    DamageFX        = None
  End

  ; *** ENGINEERING Parameters ***
  KindOf = PROJECTILE SMALL_MISSILE
  Body = ActiveBody ModuleTag_02
    MaxHealth       = 100.0
    InitialHealth   = 100.0

    ; Subdual damage "Subdues" you (reaction defined by BodyModule) when it passes your max health.
    ; The cap limits how extra-subdued you can be, and the other numbers detemine how fast it drains away on its own.
    ; A projectile is not disabled, but instead loses target and scatters
    SubdualDamageCap = 200
    SubdualDamageHealRate = 100000
    SubdualDamageHealAmount = 50
  End

; ---- begin Projectile death behaviors
  Behavior = InstantDeathBehavior DeathModuleTag_01
    DeathTypes = NONE +DETONATED
    ; we detonated normally.
    ; no FX, just quiet destroy ourselves
  End
  Behavior = InstantDeathBehavior DeathModuleTag_02
    DeathTypes = NONE +LASERED
    ; shot down by laser.
    FX         = FX_GenericMissileDisintegrate
    OCL        = OCL_GenericMissileDisintegrate
  End
  Behavior = InstantDeathBehavior DeathModuleTag_03
    DeathTypes = ALL -LASERED -DETONATED
    ; shot down by nonlaser.
    FX         = FX_GenericMissileDeath
  End
; ---- end Projectile death behaviors
    
  Behavior = PhysicsBehavior ModuleTag_06
    Mass = 1
  End
  Behavior = MissileAIUpdate ModuleTag_07
    TryToFollowTarget               = No
    FuelLifetime                    = 3000
    InitialVelocity                 = 150                ; in dist/sec
    IgnitionDelay                   = 0
    DistanceToTravelBeforeTurning   = 3
    IgnitionFX                      = FX_BuggyMissileIgnition
  End
  Locomotor = SET_NORMAL MissileDefenderMissileLocomotor
  Geometry = Sphere
  GeometryIsSmall = Yes
  GeometryMajorRadius = 2.0
End

Currently learning how to create 3D models with GMAX so that I can make my C&C Generals Zero Hour mod even more better. 🙂
Sponsor
Zatsupachi
10 years ago
I don't know exactly what happens with the code here...
Though.
You can use FireWeaponWhenDead multiple times on the main missile object.
The Weapon you fire here has 0 damage and ScatterRadius if you want but, when the projectile of this weapon detonates, this object triggers its own FireWeaponWhenDead module-- this is the one that deals actual damage.

EDIT:
Here's one I did from my mod...

The Objects



;------------------------------------------------------------------------------
Object ASpt_NukeCannonShell

  ; *** ART Parameters ***
  Draw = W3DModelDraw ModuleTag_01
    ConditionState = NONE
      Model = AVTankShel
      ParticleSysBone = NONE ArtilleryBarrageTrail
      ParticleSysBone = NONE ArtilleryBarrageTrailRing
    End
  End

  ; ***DESIGN parameters ***
  DisplayName       = OBJECT:TankShell
  EditorSorting     = SYSTEM
  ArmorSet
    Armor = ProjectileArmor
  End
  VisionRange = 0.0  


  ; *** AUDIO Parameters ***
  SoundAmbient = NukeCannonIncomingWhistle

  ; *** ENGINEERING Parameters ***
  KindOf = PROJECTILE
  Body = ActiveBody ModuleTag_02
    MaxHealth       = 100.0
    InitialHealth   = 100.0
  End

  Behavior = DestroyDie ModuleTag_03
    ;nothing
  End
    
  Behavior = DumbProjectileBehavior ModuleTag_04
    ; To tweak a Bezier path, please see GS
    FirstHeight = 50  ; Height of Bezier control points above highest intervening terrain
    SecondHeight = 150
    FirstPercentIndent = 30% ; Percentage of shot distance control points are placed
    SecondPercentIndent = 70%
    FlightPathAdjustDistPerSecond   = 0 ; Can allow a max speed this can attempt to follow a target. Units are their velocity we can tag.
  End

  Behavior = PhysicsBehavior ModuleTag_05
    Mass = 0.01   ; we can't have a zero mass, but we want it pretty tiny...
  End

  Behavior = LifetimeUpdate ModuleTag_06
    MinLifetime       = 1000   
    MaxLifetime       = 1200   
  End

  Behavior = FireWeaponWhenDeadBehavior ModuleTag_10
    DeathWeapon   = ASpt_ScatterShellAestheticWeapon
    StartsActive  = Yes                      
  End
  Behavior = FireWeaponWhenDeadBehavior ModuleTag_102
    DeathWeapon   = ASpt_ScatterShellAestheticWeapon
    StartsActive  = Yes                      
  End
  Behavior = FireWeaponWhenDeadBehavior ModuleTag_103
    DeathWeapon   = ASpt_ScatterShellAestheticWeapon
    StartsActive  = Yes                      
  End
  Behavior = FireWeaponWhenDeadBehavior ModuleTag_104
    DeathWeapon   = ASpt_ScatterShellAestheticWeapon
    StartsActive  = Yes                      
  End
  Behavior = FireWeaponWhenDeadBehavior ModuleTag_105
    DeathWeapon   = ASpt_ScatterShellAestheticWeapon
    StartsActive  = Yes                      
  End

  Geometry = Sphere
  GeometryIsSmall = Yes
  GeometryMajorRadius = 1.0

End


Object ASpt_MiniShells

  ; *** ART Parameters ***
  Draw = W3DModelDraw ModuleTag_01
    ConditionState = NONE
      Model = AVTankShel
      ParticleSysBone = NONE CzAM_MiniShellTrail
    End
  End

  ; ***DESIGN parameters ***
  Side = China
  EditorSorting     = SYSTEM
  ArmorSet
    Conditions      = None
    Armor           = ProjectileArmor
    DamageFX        = None
  End
  VisionRange       = 0.0  

  ; *** AUDIO Parameters ***

  ; *** ENGINEERING Parameters ***
  KindOf            = PROJECTILE
  Body              = ActiveBody ModuleTag_02
    MaxHealth       = 100.0
    InitialHealth   = 100.0
  End

  Behavior              = PhysicsBehavior ModuleTag_03
    Mass                = 75.0
    AerodynamicFriction = 2     ; this is now friction-per-sec
    ForwardFriction     = 2     ; this is now friction-per-sec
    CenterOfMassOffset  = 2     ; Default of 0 means nothing tips as it falls.  Positive tips forward, negative tips back
  End

  ; it may seem odd to have a "bomb" with a Locomotor, especially a Thrust locomotor,
  ; but there's a good reason: the Aurora moves so freakin' fast that it's really
  ; hard to (1) find a reliable drop location, and (2) actually get it close enough to
  ; that location. So we cheat: just get fairly close, then let the "bomb" do a little (subtle)
  ; navigation on the way down. This works pretty well and actually looks much better
  ; than you might think. (srj)
  Behavior = MissileAIUpdate ModuleTag_04
    TryToFollowTarget   = No 
    FuelLifetime        = 0
    IgnitionDelay       = 0
    InitialVelocity     = 0                ; in dist/sec
    DistanceToTravelBeforeTurning = 0
    DistanceToTargetBeforeDiving  = 0
  End
  Locomotor = SET_NORMAL AuroraBombLocomotor   ; yes, that's right.



  Scale = 0.75
  Geometry = Sphere
  GeometryIsSmall = Yes
  GeometryMajorRadius = 1.0

End


The Weapons



;------------------------------------------------------------------------------
Weapon ASpt_ShellCannonWeapon ;wouldn't be used till later part of modding.
  PrimaryDamage           = 400.0
  PrimaryDamageRadius     = 50.0
  SecondaryDamage         = 20.0
  SecondaryDamageRadius   = 60.0
  ScatterRadiusVsInfantry = 30.0     ;When this weapon is used against infantry, it can randomly miss by as much as this distance.
  AttackRange             = 350.0
  MinimumAttackRange      = 150.0
  DamageType              = EXPLOSION
  DeathType               = EXPLODED
  WeaponSpeed             = 200         ; dist/sec 
  ProjectileObject        = ASpt_NukeCannonShell
  ;FireFX                  = WeaponFX_NukeCannonMuzzleFlash
  FireSound               = NukeCannonWeapon
  ;VeterancyFireFX         = HEROIC WeaponFX_HeroicNukeCannonMuzzleFlash
  ;ProjectileDetonationFX  = WeaponFX_NukeCannon
  ;ProjectileDetonationOCL = OCL_RadiationFieldMedium
  RadiusDamageAffects     = SUICIDE SELF ALLIES ENEMIES NEUTRALS NOT_SIMILAR
  DelayBetweenShots       = 10000        ; time between shots, msec
  ClipSize                = 0            ; how many shots in a Clip (0 == infinite)
  ClipReloadTime          = 0            ; how long to reload a Clip, msec
End



;------------------------------------------------------------------------------
Weapon ASpt_ScatterShellAestheticWeapon   
  PrimaryDamage           = 120.0            
  PrimaryDamageRadius     = 30.0      
  AttackRange             = 300.0
  ScatterRadius           = 80
  DamageType              = EXPLOSION
  DeathType               = EXPLODED
  WeaponSpeed             = 99999
  ProjectileObject        = ASpt_MiniShells
  FireFX                  = WeaponFX_NukeCannonMuzzleFlash
  VeterancyFireFX         = HEROIC WeaponFX_HeroicNukeCannonMuzzleFlash
  ProjectileDetonationFX  = WeaponFX_NukeCannon
  ProjectileDetonationOCL = OCL_RadiationFieldMedium
  RadiusDamageAffects     = ALLIES ENEMIES NEUTRALS NOT_SIMILAR
  ClipSize                = 1                        ; how many shots in a Clip (0 == infinite)
  ClipReloadTime          = 99999              ; how long to reload a Clip, msec
  AutoReloadsClip         = RETURN_TO_BASE                 ; must return to base to reload this weapon
  ShowsAmmoPips           = Yes

  ; note, these only apply to units that aren't the explicit target 
  ; (ie, units that just happen to "get in the way"... projectiles
  ; always collide with the Designated Target, regardless of these flags
  ProjectileCollidesWith  = STRUCTURES
End

"It's precision_bomber."
Death Label HAS BEEN RELEASED(go get v0.99):
http://www.moddb.com/mods/death-label/downloads/death-label-ver-099 
Next Episode:
precision_bomber's Zero Hour SCIENCE!
Tank Destroyer
10 years ago
Well it kinda works(Just gonna have to tweak it a bit tho). But I have another question, is it possible to make a unit have an upgrade as a requirement? Whenever I try to do something like:

  Prerequisites
    Object                = AWATDAirfield
    Upgrade               = Upgrade_AWATDPlasmaWeapons ; This always makes it crash            
  End
Then it always results in an crash. I want to make some units buildable only when an upgrade is already researched... Help please?
Currently learning how to create 3D models with GMAX so that I can make my C&C Generals Zero Hour mod even more better. 🙂
acidbrain
10 years ago
Maybe you can add 'Options = NEED_UPGRADE' to your construction commandbutton.


CommandButton Command_ConstructYourThing
  Command          = UNIT_BUILD
  Object           = YourThing
  Options          = NEED_UPGRADE
  Upgrade          = Upgrade_AWATDPlasmaWeapons
  TextLabel        = CONTROLBAR:ConstructYourThing
  ButtonImage      = ImageHere
  ButtonBorderType = BUILD
  DescriptLabel    = CONTROLBAR:ToolTipBuildYourThing
End

;Add this to the object code
  Prerequisites
    Object = AWATDAirfield            
  End
Dont know if it works, didnt test it...
Greetz
Panem et kirkinses
Gameanater
10 years ago
Although I don't think this is very close at all to what you have in mind, you could try using "ProjectileDetonationOCL" in the weapon code to spawn an OCL that creates several units that wait a few seconds to explode or just explode instantly, if that's possible.
Any old friends still on here can add me on discord @jcdenton2187. I'm far more likely to respond there.
Tank Destroyer
10 years ago
Hmm, that idea I thought of came from this  video(notice in the video how the missiles split apart just when they're about to hit an enemy unit)
Currently learning how to create 3D models with GMAX so that I can make my C&C Generals Zero Hour mod even more better. 🙂