The 3rd Age

JUS_SAURON - The Power Of The Ring

JUS_SAURON - The Power Of  The Ring

New Powers , Heroes and Units for all Factions

Button for The 3rd AgeButton for The Dwarf HoldsButton for The Elven AllianceButton for Helm's Deep Last HopeButton for GothmogtheOrcButton for BFME+Button for The Four AgesButton for HDR HeadquartersButton for Middle Earth CenterButton for Project Perfect Mod

Become an affiliate!

   

Quick Lists

Top Rated Popular New Updated Last Comments Users

Register and log in to move these advertisements down

Rohirrim Archer Turret Horde

Avatar of Rob38

Rob38

Category: Code
Level: Expert
Created: Saturday January 19, 2008 - 22:07
Updated: Sunday March 20, 2011 - 13:22
Views: 9967
Summary: Getting Rohirrim Archers to fire while moving

Rating

Staff says

4.5

Members say

4.0

Average

4.2/5.0

10 votes

Page 1 2 3 4 5 6
1. Ok, first thing to do is have your unit and horde work properly. Don't worry about anything else before that. This will avoid complications later on.

2. Right now, let's just focus on the unit object. I'll go over the horde later to avoid confusion. First, change the draw module in your unit to:
              
Code

Draw = W3DTankDraw ModuleTag_01 ;for turrets

This allows turrets to work for your object.

3. Change your model condition by adding the turret part to it:
              
Code

        ExtraPublicBone = FIREAROWTIP ;Turret01
        
        ; bow
        DefaultModelConditionState
            Model         = rurhrmarchHD
            WeaponLaunchBone = PRIMARY FIREAROWTIP
            Turret = FIREAROWTIP ;B_SPINE1 ;BAT_SPINE2
        End


4. If you notice, the rohirrim archers already have animations for attacking while moving. Perhaps EA originally planned to have them perform this. Nobody really knows... Here's the code in their animation part:
              
Code

; Shooting whilst moving - 4 versions, one for each side.
        ;---------------------------------------------------------------------------------------------------------
        AnimationState        =    FIRING_OR_PREATTACK_A MOVING TURRET_ANGLE_90
            Animation        =    MoveAndFireBow
                AnimationName    =    RURhrmArch_SKL.RURhrmArch_ATKF
                AnimationMode    =    ONCE
                AnimationBlendTime    =    15
            End
            Flags            = MAINTAIN_FRAME_ACROSS_STATES
            FrameForPristineBonePositions = 20
        End
        AnimationState        =    FIRING_OR_PREATTACK_A MOVING TURRET_ANGLE_180
            Animation            =    MoveAndFireBow
                AnimationName    =    RURhrmArch_SKL.RURhrmArch_ATKH
                AnimationMode        =    ONCE
                AnimationBlendTime    =    15
            End
            Flags                = MAINTAIN_FRAME_ACROSS_STATES
            FrameForPristineBonePositions = 20
        End
        AnimationState        =    FIRING_OR_PREATTACK_A MOVING TURRET_ANGLE_270
            Animation            =    MoveAndFireBow
                AnimationName    =    RURhrmArch_SKL.RURhrmArch_ATKJ
                AnimationMode        =    ONCE
                AnimationBlendTime    =    15
            End
            Flags                = MAINTAIN_FRAME_ACROSS_STATES
            FrameForPristineBonePositions = 20
        End
        AnimationState            =    FIRING_OR_PREATTACK_A MOVING
            Animation            =    MoveAndFireBow
                AnimationName    =    RURhrmArch_SKL.RURhrmArch_ATKD
                AnimationMode    =    ONCE
                AnimationBlendTime    =    15
            End
            Flags                = MAINTAIN_FRAME_ACROSS_STATES
            FrameForPristineBonePositions = 20
        End
        ;---------------------------------------------------------------------------------------------------------


5. Ok, pretty simple so far. But now, however, is where the magic really begins. Create two new weaponsets for your unit.

              
Code

    WeaponSet
        Conditions = None
        Weapon = PRIMARY RohanRohirrimBowHD ;350
        AutoChooseSources = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End

    WeaponSet
        Conditions = WEAPONSET_CREATE_A_HERO_WS_01
        Weapon = PRIMARY RohanRohirrimBowMovingHD
        AutoChooseSources = PRIMARY FROM_PLAYER FROM_SCRIPT FROM_AI
    End


What is the purpose of this you ask? Well, for one, it will make them perform much better in-game (explained later on). Two, this will allow us to change the accuracy of the attack depending on whether they are moving or not! (also explained later on) Just trust me on this for now ;)

6. Create two new weapons in weapon.ini.
              
Code

Weapon RohanRohirrimBowHD ; BALANCE Archer Weapon
    AttackRange = ROHAN_HORSEBOW_RANGE ;350

    RangeBonusMinHeight    = 10
    RangeBonus        = 1
    RangeBonusPerFoot    = 1 ; ;#MULTIPLY( ROHAN_HORSEBOW_RANGE .01 )    
    
    WeaponSpeed = 321 ; dist/sec
    MinWeaponSpeed = 241
    MaxWeaponSpeed = 481     FireFX = FX_RohanArcherBowWeapon
    ScaleWeaponSpeed = Yes
    HitPercentage = 75
    ScatterRadius = 16.0
    PreAttackDelay = 700
    PreAttackType = PER_SHOT     PreAttackRandomAmount = 1000 ;200
    FiringDuration = 1500
    RequireFollowThru    = Yes

    ClipSize                 = 1
    AutoReloadsClip             = Yes
    ClipReloadTime             = 1500

    IsAimingWeapon = Yes
    AntiAirborneVehicle     = Yes
    AntiAirborneMonster     = Yes

    ; CanFireWhileMoving     = Yes
    ; CanFireWhileCharging     = Yes

    CanBeDodged = Yes
    HitPassengerPercentage = 20%

    ProjectileNugget    ; Default arrow
        ProjectileTemplateName = RohanArcherArrowProjectile
        WarheadTemplateName = RohirrimBowWarheadHD
        ForbiddenUpgradeNames = Upgrade_RohanRedArrowsStrong
    End
    ProjectileNugget    ; Fire arrow avialble through fire upgrade
        ProjectileTemplateName = RohanArcherUpgradeArrowProjectile
        WarheadTemplateName = RohirrimBowRedArrowsWarheadHD
        RequiredUpgradeNames = Upgrade_RohanRedArrowsStrong
    End
End

Weapon RohanRohirrimBowMovingHD ; BALANCE Archer Weapon
    AttackRange = ROHAN_HORSEBOW_RANGE ;350

    RangeBonusMinHeight    = 10
    RangeBonus        = 1
    RangeBonusPerFoot    = 1 ; ;#MULTIPLY( ROHAN_HORSEBOW_RANGE .01 )
    
    
    WeaponSpeed = 321 ; dist/sec
    MinWeaponSpeed = 241
    MaxWeaponSpeed = 481
    FireFX = FX_RohanArcherBowWeapon
    ScaleWeaponSpeed = Yes
    HitPercentage = 45                    ScatterRadius = 30.0
    PreAttackDelay = 700
    PreAttackType = PER_SHOT                  PreAttackRandomAmount = 200
    FiringDuration = 1500             RequireFollowThru     = Yes

    ClipSize                 = 1
    AutoReloadsClip             = Yes
    ClipReloadTime             = 1500

    RotatingTurret     = Yes
    IsAimingWeapon = Yes
    AntiAirborneVehicle     = Yes
    AntiAirborneMonster     = Yes

    CanFireWhileMoving     = Yes
    CanFireWhileCharging     = Yes

    CanBeDodged = Yes
    HitPassengerPercentage = 20%

    ProjectileNugget    ; Default arrow
        ProjectileTemplateName = RohanArcherArrowProjectile
        WarheadTemplateName = RohirrimBowWarheadHD
        ForbiddenUpgradeNames = Upgrade_RohanRedArrowsStrong
    End
    ProjectileNugget    ; Fire arrow avialble through fire upgrade
        ProjectileTemplateName = RohanArcherUpgradeArrowProjectile
        WarheadTemplateName = RohirrimBowRedArrowsWarheadHD
        RequiredUpgradeNames = Upgrade_RohanRedArrowsStrong
    End
End


Let me explain some important things in these weapons. For RohanRohirrimBowHD, you see the accuracy is pretty high (75%). You will also notice that the CanFireWhileMoving is commented out. Keep it that way! For RohanRohirrimBowMovingHD, you will notice the accuracy is much lower (45%). Also, I added three extremely important parts to it. They are:
              
Code

RotatingTurret     = Yes
CanFireWhileMoving     = Yes
CanFireWhileCharging     = Yes


You must have those in order for everything to work properly!

7. Now set up the AIUpdateInterface module with the approiate turret part. You can change the numbers to whatever you think is best.
              
Code

Behavior = AIUpdateInterface ModuleTag_03
        AutoAcquireEnemiesWhenIdle    = Yes ATTACK_BUILDINGS
        AILuaEventsList        = RohirrimArcherHDFunctions
        AttackPriority                = AttackPriority_Cavalry
        Turret
            TurretTurnRate = 180        ; turn rate, in degrees per sec
            ;;;TurretPitchRate = 30        ; does not pitch
            ControlledWeaponSlots = PRIMARY
        
;;;; Use these to restrict the firing arc of the turret ;;;
            NaturalTurretAngle = 0        ; Natural angle of the turret relative to the front of the object
            TurretMaxDeflectionCW = 180 ;90    ; Maximum deflection of the turrect clockwise from the natural turret angle
            TurretMaxDeflectionACW = 180    ; Maximum deflection of the turrect anti-clockwise from the natural turret angle
;;;; -------------------------------------------------- ;;;
        End

    End

Links / Downloads

 HitsAdded
Tank turrets in BFME 2 Tutorial2181January 19, 2008 - 22:23

Comments

Display order: Newest first

Carthaen - Wednesday April 12, 2017 - 12:49

I don't understand why it's not working... I did all like it was in tutorial. I tried to do it for Rivendell Archers in ROTWK... And it was no results...

drogoth232 - Tuesday May 5, 2009 - 14:05

Where do I find scriptevents.xml?

Rob38 (Team Chamber Member) - Friday May 23, 2008 - 16:04

It depends on how advanced you want your setup to be. The scripts allows for two different weaponsets to be created, one for moving and one for not moving. This is so that I can change attack power, accuracy, etc. You can try to set it up without the scripts, but I'm not sure how well it will work.

galentv - Friday May 23, 2008 - 11:25

is the scriptevents.xml and scripts.lua very necessary? Please say no, because i dont know how to get them...

Rob38 (Team Chamber Member) - Wednesday January 23, 2008 - 19:41

Well, first, I don't think there are animations for Theoden swinging his sword on both sides of the horse. Second, you would have two melee attacks being performed at the same time so I don't really know how well that would work. But I think it would be possible, although it may look a little bit strange ;)

Dwar the wolf - Tuesday January 22, 2008 - 4:04

can this done with Theoden while charging he attacks with his sword only (no bow) also how to make him use both hands in attack when mounting to left and right ..( like in movie in Helmsdeep)

Sulherokhh (Team Chamber Member) - Sunday January 20, 2008 - 8:27

Yeehaa! Different WeaponSets! Veeery neat! :)

Go to top

 

"One site to rule them all, one site to find them,
one site to host them all, and on the network bind them."

 
10:21:24