;----------------------------------------------------------------
; Blinde Raserei Stufe 1 (+Angriff -Rüstung)
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukRaserei1
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus1
        TriggeredBy             = Upgrade_Level_3
    End
    Behavior = SpecialPowerModule ModuleTag_UglukRasereiStarter1                ; SpecialAbility is a SpecialPower, SpecialPower is anyting special
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus1
        StartsPaused            = No
    End
    Behavior = HeroModeSpecialAbilityUpdate ModuleTag_UglukRasereiUpdate1   ; So the difference in SpecialAbility is that it takes timing from this Update, instead of simply firing.
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus1
        HeroAttributeModifier   = UglukCarnageStufe1
        HeroEffectDuration      = 30000 ; this should sync with the auto ability delay re-fire time in commandButtons.ini
        UnpackTime              = 1 ; insant unpack
        TriggerSound            = AragornBladeMaster
    End
;----------------------------------------------------------------
; Blinde Raserei Stufe 2 (+Geschwindigkeit -Experience)
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukRaserei2
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus2
        TriggeredBy             = Upgrade_Level_3
    End
    Behavior = SpecialPowerModule ModuleTag_UglukRasereiStarter2                ; SpecialAbility is a SpecialPower, SpecialPower is anyting special
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus2
        StartsPaused            = No
    End
    Behavior = HeroModeSpecialAbilityUpdate ModuleTag_UglukRasereiUpdate2   ; So the difference in SpecialAbility is that it takes timing from this Update, instead of simply firing.
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus2
        HeroAttributeModifier   = UglukCarnageStufe2
        HeroEffectDuration      = 30000 ; this should sync with the auto ability delay re-fire time in commandButtons.ini
        UnpackTime              = 1 ; insant unpack
        TriggerSound            = AragornBladeMaster
    End
;----------------------------------------------------------------
; Blinde Raserei Stufe 3 (+Angriffsgeschwindigkeit -Sichtweite)
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukRaserei3
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus3
        TriggeredBy             = Upgrade_Level_3
    End
    Behavior = SpecialPowerModule ModuleTag_UglukRasereiStarter3                ; SpecialAbility is a SpecialPower, SpecialPower is anyting special
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus3
        StartsPaused            = No
    End
    Behavior = HeroModeSpecialAbilityUpdate ModuleTag_UglukRasereiUpdate3   ; So the difference in SpecialAbility is that it takes timing from this Update, instead of simply firing.
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus3
        HeroAttributeModifier   = UglukCarnageStufe3
        HeroEffectDuration      = 30000 ; this should sync with the auto ability delay re-fire time in commandButtons.ini
        UnpackTime              = 1 ; insant unpack
        TriggerSound            = AragornBladeMaster
    End
;----------------------------------------------------------------
; Blinde Raserei Stufe 4 (+Stichwaffen-Resist -Pfeile-Resist)
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukRaserei4
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus4
        TriggeredBy             = Upgrade_Level_3
    End
    Behavior = SpecialPowerModule ModuleTag_UglukRasereiStarter4             ; SpecialAbility is a SpecialPower, SpecialPower is anyting special
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus4
        StartsPaused            = No
    End
    Behavior = HeroModeSpecialAbilityUpdate ModuleTag_UglukRasereiUpdate4   ; So the difference in SpecialAbility is that it takes timing from this Update, instead of simply firing.
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus4
        HeroAttributeModifier   = UglukCarnageStufe4
        HeroEffectDuration      = 30000 ; this should sync with the auto ability delay re-fire time in commandButtons.ini
        UnpackTime              = 1 ; insant unpack
        TriggerSound            = AragornBladeMaster
    End
;----------------------------------------------------------------
; Blinde Raserei Stufe 5 (+Knockback-resist +Crushable-Level Stufe 5 -Leben)
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukRaserei5
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus5
        TriggeredBy             = Upgrade_Level_3
    End
    Behavior = SpecialPowerModule ModuleTag_UglukRasereiStarter5                ; SpecialAbility is a SpecialPower, SpecialPower is anyting special
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus5
        StartsPaused            = No
    End
    Behavior = HeroModeSpecialAbilityUpdate ModuleTag_UglukRasereiUpdate5   ; So the difference in SpecialAbility is that it takes timing from this Update, instead of simply firing.
        SpecialPowerTemplate    = SpecialAbilityUglukRasereiModus5
        HeroAttributeModifier   = UglukCarnageStufe5
        HeroEffectDuration      = 30000 ; this should sync with the auto ability delay re-fire time in commandButtons.ini
        UnpackTime              = 1 ; insant unpack
        TriggerSound            = AragornBladeMaster
    End
;---------------------------------------------------------------------
; Harter Marsch
;---------------------------------------------------------------------
    Behavior                                = UnpauseSpecialPowerUpgrade ModuleTag_TheodenGloriousChargeEnabler
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        TriggeredBy                         = Upgrade_Level_7
    End
    Behavior                                = SpecialPowerModule ModuleTag_TheodenGloriousChargeUpdate
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        UpdateModuleStartsAttack            = Yes
        StartsPaused                        = Yes
        AttributeModifier                   = UglukHardMarch
        AttributeModifierRange              = 200
        AttributeModifierAffectsSelf        = Yes
        AttributeModifierAffects            = ANY +URUK ALLIES
        AttributeModifierFX                 = FX_UglukHardMarchFX
    End
    Behavior                                = SpecialAbilityUpdate ModuleTag_GloriousChargeAnimation
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        PreparationTime                     = 0
        PersistentPrepTime                  = 0
        PackTime                            = 1330
        UnpackTime                          = 1000
        UnpackingVariation                  = 2
    End
;---------------------------------------------------------------------
; Ugluks Uruks
;---------------------------------------------------------------------
    Behavior                    = UnpauseSpecialPowerUpgrade ModuleTag_DainSummonEnabler
        SpecialPowerTemplate    = SpecialAbilityDainSummonRoyalGuard
        TriggeredBy             = Upgrade_Level_10
    End
    Behavior                    = OCLSpecialPower ModuleTag_OCLSpecialPower
        SpecialPowerTemplate    = SpecialAbilityDainSummonRoyalGuard
        OCL                     = OCL_SpawnIsengardUglukHorde
        CreateLocation          = CREATE_AT_LOCATION
        TriggerFX               = FX_SummonWildmen
        StartsPaused            = Yes
        SetModelCondition       = ModelConditionState:EMOTION_CELEBRATING
        SetModelConditionTime   = 2.1
    End
;;; --------------------------------------------------------
;;; Auto Heilen
;;; --------------------------------------------------------
    Behavior = AutoHealBehavior ModuleTag_UglukHealing
        StartsActive = Yes
        HealingAmount = HERO_HEAL_AMOUNT
        HealingDelay = 1000
        StartHealingDelay = HERO_HEAL_DELAY
        HealOnlyIfNotInCombat = Yes
    End
    
    ;///////////////////
    ; AISpecialPowers
    ;///////////////////
    
    Behavior = AISpecialPowerUpdate CarnageAI
        CommandButtonName = Command_UglukBerserker
        SpecialPowerAIType = AI_SPECIAL_POWER_BASIC_SELF_BUFF
    End
    
    Behavior = AISpecialPowerUpdate SpecialPowerAragornAthelas
        CommandButtonName = Command_SpecialAbilityuglukAthelas
        SpecialPowerAIType = AI_SPECIAL_POWER_SELFAOEHEALHEROS
        SpecialPowerRadius = 30.0
    End
    Behavior = AISpecialPowerUpdate SpecialPowerTheodenGloriousCharge
        CommandButtonName = Command_SpecialAbilityUglukHardMarch
        SpecialPowerAIType = AI_SPECIAL_POWER_BASIC_SELF_BUFF
    End
    Behavior = AISpecialPowerUpdate RoyalGuardAI
        CommandButtonName = Command_SpecialAbilityUglukUruk
        SpecialPowerAIType = AI_SPECIAL_POWER_TARGETAOE_SUMMON
        SpecialPowerRadius = 30.0
    End
    Geometry            = CYLINDER
    GeometryMajorRadius = 8.0
    GeometryHeight        = 19.2
    GeometryIsSmall        = Yes
    Shadow                = SHADOW_DECAL
    ShadowSizeX            = 19
    ShadowSizeY            = 19
    ShadowTexture        = ShadowI
    Geometry            = CYLINDER
    GeometryMajorRadius = 8.0
    GeometryHeight        = 19.2
    GeometryIsSmall        = Yes
    Shadow                = SHADOW_DECAL
    ShadowSizeX            = 19
    ShadowSizeY            = 19
    ShadowTexture        = ShadowI
End
ChildObject  IsengardUgluk_modMember IsengardUgluk_mod
    MaxSimultaneousOfType = 1
    ThingClass = HORDE_UNIT ;;;CHARACTER_UNIT
  Behavior = HordeMemberCollide ModuleTag_HMC
    ;nothing
  End
    CommandSet = IsengardUglukFighterSystemComboHordeCommandSet
End
Object IsengardUglukHordeSystem
    ButtonImage = HIUgluk
    SelectPortrait = HPUgluk
    
    Draw = W3DScriptedModelDraw ModuleTag_W3DModelDraw
        DependencySharedModelFlags = EMOTION_ALERT EMOTION_MORALE_HIGH EMOTION_MORALE_LOW EMOTION_AFRAID EMOTION_COWER SELECTED EMOTION_TERROR EMOTION_LOOK_TO_SKY
        DefaultModelConditionState
            Model = None ;InvisHrdeTmp
        End
        ModelConditionState = HORDE_EMPTY
            Model = None
        End        
        ModelConditionState = WORLD_BUILDER
            Model = HordeMarkIUHai
        End
    End
    
    Side = Isengard
    EditorSorting = UNIT
    EmotionRange = 240
    DisplayName = OBJECT:IsengardUgluk
    
    WeaponSet
        Conditions         = None 
        Weapon             = PRIMARY    NormalMeleeHordeRangefinder
        Weapon             = QUATERNARY NormalMeleeHordeRangefinder
        AutoChooseSources  = QUATERNARY NONE
    End
    BuildCost         = UGLUK_BUILDCOST
    BuildTime         = UGLUK_BUILDTIME  
            
    VisionRange = VISION_STANDARD_HORSE                
    ShroudClearingRange = SHROUD_CLEAR_HERO    
    
    VisionSide         = 50%
    VisionRear         = 25%
    
    MaxVisionBonusPercent     = 300%
    VisionBonusTestRadius     = 200
    VisionBonusPercentPerFoot = 1.0%
    MaxSimultaneousOfType = 1
    CommandSet = UglukCommandSet
    CommandPoints = UGLUK_COMMAND_POINTS    
    CrushableLevel       = 2          ; What am I?:        0 = for infantry, 1 = for trees, 2 = general vehicles
    CrusherLevel         = 0         ; What can I crush?: 0 = small animals, 1 = infantry, 2 = trees, 3 = vehicles 
      
    FormationWidth         = 2         ; Width it occupies in formations. Current choices are 1 or 2.
    FormationDepth         = 2         ; Depth it occupies in formations. Current choices are 1 or 2.
    
    TransportSlotCount = TRANSPORTSLOTCOUNT_SMALL_HORDE
    KindOf = SELECTABLE CAN_ATTACK ATTACK_NEEDS_LINE_OF_SIGHT CAN_USE_SIEGE_TOWER INFANTRY HORDE MELEE_HORDE ARMY_SUMMARY URUK LARGE_RECTANGLE_PATHFIND;UNATTACKABLE 
    
    ThreatLevel = ISENGARD_FIGHTER_HORDE_THREAT
    ThreatBreakdown IsengardFighterHorde_DetailedThreat
        AIKindOf = INFANTRY
    End
    
    #include "..\..\..\includes\StandardHordeEvaEvents.inc"
    Body = ImmortalBody ModuleTag_ImmortalBody
        MaxHealth = 1
    End
    
    ; *** MODULES ***
    Behavior = SiegeDeployHordeSpecialPower SiegeDeployHordeSpecialPowerModuleTag
        SpecialPowerTemplate = SpecialAbilitySiegeDeploy
    End
    
    Behavior = StancesBehavior ModuleTag_StancesBehavior
        StanceTemplate = Hero
    End
    Behavior = HordeAIUpdate ModuleTag_HordeAIUpdate
        AutoAcquireEnemiesWhenIdle     = Yes ATTACK_BUILDINGS
        MoodAttackCheckRate            = 500
        AILuaEventsList            = InfantryFunctions
        MaxCowerTime            = 5000
        MinCowerTime            = 3000
        AILuaEventsList                = InfantryFunctions
        AttackPriority                = AttackPriority_Infantry
        
    End
    
    Behavior = HordeContain ModuleTag_HordeContain
        FrontAngle         = 270
        FlankedDelay         = 2000
        ObjectStatusOfContained = 
        InitialPayload         = IsengardUgluk_modMember 1
        Slots             = 1
        PassengerFilter        = NONE +INFANTRY +HERO
        ShowPips         = No
        ThisFormationIsTheMainFormation = Yes    ;Used to determine which armorset to use (and anything else we want!)
        RandomOffset        = X:3 Y:3
        MeleeBehavior         = Amoeba
        End
   
        RankInfo = RankNumber:1 UnitType:IsengardUgluk_modMember Position:X:0 Y:0
        
        RanksToReleaseWhenAttacking = 1 
        ; Normal Formations  
        ComboHorde = Target:IsengardFighterHorde             Result:IsengardUglukComboHorde        InitiateVoice:UrukWarriorVoiceJoin 
        MeleeAttackLeashDistance = 1        ; How far the hordes can move from the center of the horde when melee attacking.                
        BackUpMinDelayTime    = 1        ; The minimum amount of time to delay before backing up
        BackUpMaxDelayTime    = 3000        ; The maximum amount of time to delay before backing up
        BackUpMinDistance    = 1        ; The minimum number of cells to backup
        BackUpMaxDistance    = 3        ; The maximum number of cells to backup
        BackupPercentage    = 80%        ; The amount of chance that a unit will back up.
    End
    
    Behavior = PhysicsBehavior ModuleTag_PhysicsBehavior
        GravityMult = 1.0
    End
    
    Behavior = EmotionTrackerUpdate    Module_EmotionTracker
        TauntAndPointDistance                = 300
        TauntAndPointUpdateDelay            = 10000
        AddEmotion            =    Doom_Base
        //    AddEmotion            =   BraceForBeingCrushed_Base
        //    AddEmotion            =    FearIdle_Base
        //    AddEmotion            =    FearBusy_Base
        AddEmotion            =    Point_Base
        AddEmotion            =    Taunt_Base
         AddEmotion            =    CheerIdle_Base
        AddEmotion            =    CheerBusy_Base
        //    AddEmotion            =    HeroCheerIdle_Base
        //    AddEmotion            =    HeroCheerBusy_Base
        AddEmotion            =    Alert_Base
        AddEmotion            =    CheerForAboutToCrush_Base
    End
    #include "..\..\..\includes\CaptureBuilding.inc"
    LocomotorSet
        Locomotor     = NormalMeleeHordeLocomotor
        Condition     = SET_NORMAL
        Speed         = NORMAL_EVIL_HERO_SPEED
    End
    Behavior = ProductionUpdate ProductionUpdateModuleTag
        GiveNoXP = Yes
    End
    
    
    Behavior = PickupStuffUpdate ModuleTag_PickupStuffUpdate
        SkirmishAIOnly = Yes
        StuffToPickUp = NONE +CRATE
        ScanRange = 200
        ScanIntervalSeconds = 0.5
    End
    
        ;;; UGLUK PASSIVE LEADERSHIP ABILITY ;;;-----------------------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_LeadershipUnpause
        SpecialPowerTemplate        = SpecialAbilityFakeLeadership
        TriggeredBy                    = Upgrade_Level_5
    End
    Behavior = SpecialPowerModule ModuleTag_Leadership
        SpecialPowerTemplate        = SpecialAbilityFakeLeadership
        UpdateModuleStartsAttack    = No
        StartsPaused                = Yes
    End    
    Behavior = AttributeModifierAuraUpdate ModuleTag_LeadershipUpdate
        StartsActive    = No                                        ; If no, requires upgrade to turn on.
        BonusName        = UglukLeadership
        ;TriggeredBy        = Upgrade_Level_5
        RefreshDelay    = 2000
        Range            = 200
        ;AntiCategory    = BUFF
        ObjectFilter    = ANY +URUK -INFANTRY -CAVALRY -HERO -SHIP -MACHINE -MONSTER -STRUCTURE -DOZER ALLIES
    End      
;---------------------------------------
; Dunkle Medizin
;---------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_MedizinStarter
        SpecialPowerTemplate             = SpecialAbilityUglukMedizin
        TriggeredBy                      = Upgrade_Level_1
    End
    Behavior = SpecialPowerModule ModuleTag_MedizinDummy
        SpecialPowerTemplate             = SpecialAbilityUglukMedizin
        StartsPaused                     = Yes
        UpdateModuleStartsAttack         = Yes
    End
    
    Behavior = ActivateModuleSpecialPower ModuleTag_CloseTheGap
        SpecialPowerTemplate             = SpecialAbilityUglukMedizin
        StartAbilityRange                = 200
        TriggerSpecialPower              = ModuleTag_MedizinHeal          TARGETPOS
        TriggerSpecialPower              = ModuleTag_MedizinBlastStarter  TARGETPOS
    End
    
    Behavior = PlayerHealSpecialPower ModuleTag_MedizinHeal
        SpecialPowerTemplate             = SpecialAbilityActivateeDummy
        HealAmount                       = 1.0
        HealAsPercent                    = Yes
        HealAffects                      = URUK
        HealRadius                       = 80
        HealFX                           = FX_UglukSupper
        InitiateSound                    = UglukMedizinVoice
        ;TriggerFX                        = FX_DainMightyRage02
    End
    Behavior = SpecialPowerModule ModuleTag_MedizinBlastStarter       
        SpecialPowerTemplate             = SpecialAbilityWizardBlast
        UpdateModuleStartsAttack         = Yes
        StartsPaused                     = No
    End
    Behavior = WeaponFireSpecialAbilityUpdate ModuleTag_MedizinBlastWeaponFireUpdate   
        SpecialPowerTemplate             = SpecialAbilityWizardBlast
        WhichSpecialWeapon               = 1
        SkipContinue                     = Yes
        FreezeAfterTriggerDuration       = 100 ; Hold AI for this long after we fire.
        UnpackTime                       = 700
        PreparationTime                  = 1   
        ;PersistentPrepTime              = 1000
        PackTime                         = 100
        AwardXPForTriggering             = 50        
        StartAbilityRange                = ANGMAR_NECRO_FELL_STRENGTH_START_RANGE        
        SpecialWeapon                    = UglukMedizinWeapon
    End
    Behavior = AutoAbilityBehavior ModuleTag_MedizinAutoAbility
        SpecialAbility                   = SpecialAbilityUglukMedizin
        MaxScanRange                     = 150
        Query                            = 1 NONE +URUK ALLIES
    End
;----------------------------------------------------------------
; Ugluk Berserker
;----------------------------------------------------------------
    Behavior = UnpauseSpecialPowerUpgrade ModuleTag_UglukBerserkerCarnage
        SpecialPowerTemplate = SpecialAbilityUglukBerserker
        TriggeredBy          = Upgrade_Level_3
    End
    Behavior = WeaponModeSpecialPowerUpdate ModuleTag_UglukBerserkerPowerUpdate
        SpecialPowerTemplate = SpecialAbilityUglukBerserker
        Duration             = 20000                                                ; Needs to match SpecialAbilityGimliHeroMode
        AttributeModifier    = LurtzCarnage
        LockWeaponSlot       = QUATERNARY
        StartsPaused         = Yes
    End
;---------------------------------------------------------------------
; Harter Marsch
;---------------------------------------------------------------------
    Behavior                                = UnpauseSpecialPowerUpgrade ModuleTag_TheodenGloriousChargeEnabler
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        TriggeredBy                         = Upgrade_Level_7
    End
    Behavior                                = SpecialPowerModule ModuleTag_TheodenGloriousChargeUpdate
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        UpdateModuleStartsAttack            = Yes
        StartsPaused                        = Yes
        AttributeModifier                   = UglukHardMarch
        AttributeModifierRange              = 200
        AttributeModifierAffectsSelf        = Yes
        AttributeModifierAffects            = ANY +URUK ALLIES
        AttributeModifierFX                 = FX_UglukHardMarchFX
    End
    Behavior                                = SpecialAbilityUpdate ModuleTag_GloriousChargeAnimation
        SpecialPowerTemplate                = SpecialAbilityUglukHardMarch
        PreparationTime                     = 0
        PersistentPrepTime                  = 0
        PackTime                            = 1330
        UnpackTime                          = 1000
        UnpackingVariation                  = 2
    End