Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

rey Offline
#1 Posted : Tuesday, September 20, 2022 6:25:35 PM(UTC)
rey
Major
Joined: 11/6/2015(UTC)
Posts: 141

Thanks: 7 times
Was thanked: 3 time(s) in 3 post(s)
Long story short: i'm trying to let Red Guards shoot mines, so if they are detected, guards could shoot to disarm them. But for some reason mere remake of GLA worker weapon doesn't work. In some experiments infantry stopped using normal shooting weapon(wasn't able to attack any more after first anti-mine try), in some - didn't do anything to mine at all.
So can somebody please direct me how to modify red guard's weapon(or add another dedicated one) for it to be used against mines?
Sponsor
UTD^Force Offline
#2 Posted : Friday, September 23, 2022 10:37:46 AM(UTC)
UTD^Force
Colonel
C&C Labs Staff: Labs Staff MemberMaps Staff: Maps Staff Member
Joined: 8/13/2013(UTC)
Posts: 784
Jordan
Location: Middle east

Thanks: 437 times
Was thanked: 171 time(s) in 155 post(s)
Please provide the full edited code to make it easier to figure out what the problem is.
UTD^Force Offline
#3 Posted : Friday, September 23, 2022 11:31:45 AM(UTC)
UTD^Force
Colonel
C&C Labs Staff: Labs Staff MemberMaps Staff: Maps Staff Member
Joined: 8/13/2013(UTC)
Posts: 784
Jordan
Location: Middle east

Thanks: 437 times
Was thanked: 171 time(s) in 155 post(s)
Alright, so I gave it a shot and it worked.
My advice to you is to look into other units that have certain characteristics which can help you achieve your goal. And that's what I did, I looked into a couple of units that have different weapons activated by command buttons, colonel burton and the american ranger.

After I edited the weapons and found a way to let the red guard automatically switch back to his own weapon, another problem occurred. Because the red guard only has one weapon, he didn't animate disarming the mines, that's why this code is long. The first part of the code fixes the animation, while the second part fixes the weapon's issue:

Code:
CommandButton Command_DisarmMinesAtPositionRedGuard
  Command                 = FIRE_WEAPON
  WeaponSlot              = SECONDARY ; Best if this matches up with an AutoChoose listing that forbids this slot normally
  Options                 = OK_FOR_MULTI_SELECT NEED_TARGET_POS USES_MINE_CLEARING_WEAPONSET
  TextLabel               = CONTROLBAR:DisarmMinesAtPosition
  ButtonImage             = SSClearMines_L ;Don't know why this became a portrait (It's from Generals, not MD).
  ButtonBorderType        = ACTION ; Identifier for the User as to what kind of button this is
  DescriptLabel           = CONTROLBAR:ToolTipDisarmMinesAtPosition
  RadiusCursorType        = CLEARMINES
  InvalidCursorName       = GenericInvalid
End

CommandSet ChinaInfantryRedguardCommandSetNEW
  1  = Command_ChinaInfantryRedGuardCaptureBuilding
  2  = Command_DisarmMinesAtPositionRedGuard
  3  = Command_AmericaRangerSwitchToMachineGun
 ; 4  = Command_AmericaRangerSwitchToFlagBangGrenades
  11 = Command_AttackMove
  13 = Command_Guard
  14 = Command_Stop
End

Object ChinaInfantryRedguard
 RemoveModule ModuleTag_01
 AddModule
  Draw = W3DModelDraw ModuleTag_6515648

    OkToChangeModelColor = Yes

    ; this says "we don't use these condition states at all, so completely
    ; ignore them for purposes of matchmaking"... this is useful to help
    ; reduce the number of AliasConditionState clauses you must add in
    ; order to avoid ambiguity in some cases.
    IgnoreConditionStates = PREATTACK_A FIRING_A BETWEEN_FIRING_SHOTS_A RELOADING_A

    ; ------- Standing-Around Animations
 
    DefaultConditionState
      Model               = NICNSC_SKN
      IdleAnimation       = NICNSC_SKL.NICNSC_STA 0 35
      IdleAnimation       = NICNSC_SKL.NICNSC_IDA
      IdleAnimation       = NICNSC_SKL.NICNSC_IDB
      AnimationMode       = ONCE
      WeaponFireFXBone    = PRIMARY Muzzle
      WeaponMuzzleFlash   = PRIMARY MuzzleFX
      WeaponFireFXBone    = SECONDARY Muzzle
      WeaponMuzzleFlash   = SECONDARY MuzzleFX
      TransitionKey       = TRANS_Stand
    End

    ConditionState        = REALLYDAMAGED
      IdleAnimation       = NICNSC_SKL.NICNSC_STB
      AnimationMode       = ONCE
      TransitionKey       = TRANS_StandDamaged
    End

    ; ------- Machine Gun Animations

    ConditionState      = USING_WEAPON_A 
      Animation         = NICNSC_SKL.NICNSC_ATA
      AnimationMode     = LOOP
      TransitionKey     = TRANS_Firing
    End
    AliasConditionState = PREATTACK_B MOVING
    AliasConditionState = PREATTACK_B FIRING_B
    AliasConditionState = PREATTACK_B BETWEEN_FIRING_SHOTS_B

    ConditionState      = USING_WEAPON_A REALLYDAMAGED
      Animation         = NICNSC_SKL.NICNSC_ATC
      AnimationMode     = LOOP
      TransitionKey     = TRANS_FiringDamaged
    End
    AliasConditionState = PREATTACK_B MOVING REALLYDAMAGED
    AliasConditionState = PREATTACK_B FIRING_B REALLYDAMAGED
    AliasConditionState = PREATTACK_B BETWEEN_FIRING_SHOTS_B REALLYDAMAGED

    ; ------- Firing-related Transitions

    TransitionState   = TRANS_Firing TRANS_FiringDamaged
      Animation       = NICNSC_SKL.NICNSC_AA2AC
      AnimationMode   = ONCE
    End

    TransitionState   = TRANS_Stand TRANS_Firing
      Animation       = NICNSC_SKL.NICNSC_SA2AA
      AnimationMode   = ONCE
    End

    TransitionState   = TRANS_Firing TRANS_Stand
      Animation       = NICNSC_SKL.NICNSC_AA2SA
      AnimationMode   = ONCE
    End

    TransitionState   = TRANS_StandDamaged TRANS_FiringDamaged
      Animation       = NICNSC_SKL.NICNSC_ATCST
      AnimationMode   = ONCE
    End

    TransitionState   = TRANS_FiringDamaged TRANS_StandDamaged
      Animation       = NICNSC_SKL.NICNSC_ATCED
      AnimationMode   = ONCE
    End


    ; ------------- Damage Transitions --------------------
    TransitionState = TRANS_StandDamaged TRANS_RunDamaged
      Animation       = NICNSC_SKL.NICNSC_AA2AC
      AnimationMode   = ONCE
      AnimationSpeedFactorRange = 2 2
    End
    TransitionState = TRANS_RunDamaged TRANS_StandDamaged 
      Animation       = NICNSC_SKL.NICNSC_AA2AC
      AnimationMode   = ONCE_BACKWARDS
      AnimationSpeedFactorRange = 2 2
      Flags           = START_FRAME_LAST
    End
    TransitionState = TRANS_Stand TRANS_StandDamaged 
      Animation       = NICNSC_SKL.NICNSC_AA2SA
      AnimationMode   = ONCE_BACKWARDS
      AnimationSpeedFactorRange = 4 5
      Flags           = START_FRAME_LAST
    End




    ; ------- Bayonet Animations

    ConditionState    = PREATTACK_C 
      Animation       = NICNSC_SKL.NICNSC_ATB1
      AnimationMode   = ONCE
      TransitionKey   = TRANS_Stab
    End
    AliasConditionState = PREATTACK_C MOVING
    AliasConditionState = PREATTACK_C FIRING_C
    AliasConditionState = PREATTACK_C BETWEEN_FIRING_SHOTS_C

    ConditionState      = FIRING_C
      Animation         = NICNSC_SKL.NICNSC_ATB2
      AnimationMode     = ONCE
      ; this is basically a trick: this guy has a nontrivial animation for firing,
      ; and a long recycle time between shots. we want him to finish his fire animation
      ; (unless he's ordered to do something else), so this is just a handy trick that
      ; says, "if the previous state had this transition key, allow it to finish before
      ; switching to us, if possible".
      WaitForStateToFinishIfPossible = TRANS_Stab
    End
    AliasConditionState = BETWEEN_FIRING_SHOTS_C
    AliasConditionState = RELOADING_C

    ; ------- Parachuting Animations

    ConditionState    = FREEFALL
      Animation       = NICNSC_SKL.NICNSC_POP
      AnimationMode   = MANUAL
      Flags           = START_FRAME_FIRST
      TransitionKey   = TRANS_Falling
    End
    AliasConditionState = FREEFALL REALLYDAMAGED
    AliasConditionState = FREEFALL DYING

    ConditionState    = PARACHUTING
      Animation       = NICNSC_SKL.NICNSC_PHG
      AnimationMode   = LOOP
      Flags           = PRISTINE_BONE_POS_IN_FINAL_FRAME  ; our bone positions should come from the last frame, rather than the first
      TransitionKey   = TRANS_Chute
    End
    AliasConditionState = PARACHUTING REALLYDAMAGED
    AliasConditionState = PARACHUTING DYING

    TransitionState   = TRANS_Falling TRANS_Chute
      Animation       = NICNSC_SKL.NICNSC_POP
      AnimationMode   = ONCE
      Flags           = PRISTINE_BONE_POS_IN_FINAL_FRAME  ; our bone positions should come from the last frame, rather than the first
    End

    TransitionState   = TRANS_Chute TRANS_Stand
      Animation       = NICNSC_SKL.NICNSC_PTD
      AnimationMode   = ONCE
    End

    ; ------- Movement Animations

    ConditionState      = MOVING
      Animation         = NICNSC_SKL.NICNSC_RNA 26
      AnimationMode     = LOOP
      Flags             = RANDOMSTART
      TransitionKey     = None
      ParticleSysBone   = None InfantryDustTrails
    End
    AliasConditionState = MOVING ATTACKING

    ConditionState = MOVING REALLYDAMAGED
      Animation         = NICNSC_SKL.NICNSC_RNB 28
      AnimationMode     = LOOP
      Flags             = RANDOMSTART
      TransitionKey     = TRANS_RunDamaged
      TransitionKey     = None
    End
    AliasConditionState = MOVING ATTACKING REALLYDAMAGED

    ; ------- Bldg-capture

    ConditionState      = UNPACKING
      Model             = NICNSC_F_SKN
      Animation         = NICNSC_F_SKL.NICNSC_F_FDP1
      AnimationMode     = ONCE
    End
    AliasConditionState = UNPACKING REALLYDAMAGED

    ConditionState      = RAISING_FLAG
      Model             = NICNSC_F_SKN
      Animation         = NICNSC_F_SKL.NICNSC_F_FDP2
      AnimationMode     = ONCE
      TransitionKey     = TRANS_Raising
    End
    AliasConditionState = RAISING_FLAG REALLYDAMAGED

    ConditionState      = PACKING
      Model             = NICNSC_F_SKN
      Animation         = NICNSC_F_SKL.NICNSC_F_FDP1
      AnimationMode     = ONCE_BACKWARDS
      Flags             = START_FRAME_LAST
      TransitionKey     = TRANS_Packing
    End
    AliasConditionState = PACKING REALLYDAMAGED

    TransitionState     = TRANS_Raising TRANS_Packing
      Model             = NICNSC_F_SKN
      Animation         = NICNSC_F_SKL.NICNSC_F_FDP2
      AnimationMode     = ONCE_BACKWARDS
      Flags             = START_FRAME_LAST
    End

    ; ------- Dying Animations

    ConditionState      = DYING
      Animation         = NICNSC_SKL.NICNSC_DTA
      Animation         = NICNSC_SKL.NICNSC_DTB
      AnimationMode     = ONCE
      TransitionKey     = TRANS_Dying
    End

    TransitionState     = TRANS_Dying TRANS_Flailing
      Animation         = NICNSC_SKL.NICNSC_ATDE1
      AnimationMode     = ONCE
    End

    ConditionState      = DYING EXPLODED_FLAILING
      Animation         = NICNSC_SKL.NICNSC_ATDE2
      AnimationMode     = LOOP
      TransitionKey     = TRANS_Flailing
    End

    ConditionState      = DYING EXPLODED_BOUNCING
      Animation         = NICNSC_SKL.NICNSC_ATDE3
      AnimationMode     = ONCE
      TransitionKey     = None
    End

    ; ------- Misc Animations

    ConditionState      = SPECIAL_CHEERING
      Animation         = NICNSC_SKL.NICNSC_CHA
      AnimationMode     = LOOP
    End

  End
 End
;;;;;;;;;;;;;; all of that above in the redguard's code is only to let it animate disarming
  WeaponSet
    Conditions = None 
    Weapon = PRIMARY RedguardMachineGun
    Weapon = SECONDARY DozerMineDisarmingWeapon
    AutoChooseSources = PRIMARY FROM_SCRIPT FROM_AI DEFAULT_SWITCH_WEAPON
    AutoChooseSources = SECONDARY FROM_SCRIPT FROM_AI
    WeaponLockSharedAcrossSets = Yes ; This set is so similar to the default set that it can hold the weapon lock
  End
 AddModule
  Behavior = StealthDetectorUpdate ModuleTag_0655
    DetectionRate         = 500   ; how often to rescan for stealthed things in my sight (msec)
    ;DetectionRange       = ??? ;Dustin, enable this for independant balancing!
    CanDetectWhileGarrisoned  = No ;Garrisoned means being in a structure that you units can shoot out of.
    CanDetectWhileContained   = No ;Contained means being in a transport or tunnel network.
    ExtraRequiredKindOf   = MINE  ; we can only detect MINES, not other stealthed things
  End
 End
  CommandSet    = ChinaInfantryRedguardCommandSetNEW

End


Oh, and I also added the StealthDetectorUpdate behaviour to let the red guard detect mines and only mines. You can remove the last part if you don't want this.
Have a nice day, and happy modding!

#EDIT: make sure to copy the code in chronological order or the game will crash i.e. the game reads the code from the top to bottom, which means the commandbutton used in the commandset should be written before the commandset itself, or the game will crash. The same goes for the edited commandset that the redguard will use.

Edited by user Friday, September 23, 2022 11:34:37 AM(UTC)  | Reason: Not specified

Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.6.1 | YAF © 2003-2022, Yet Another Forum.NET
This page was generated in 0.518 seconds.