function GetNearestUnit takes group whichGroup, real x, real y returns unit local real currentRange local integer currentUnitId local integer FirstUnitId = H2I( FirstOfGroup( whichGroup ) ) local integer EnumUnitId local real EnumUnitRange local boolean Found local integer interGroupId if ( I2Unit( FirstUnitId ) == null ) then return null endif set EnumUnitId = FirstUnitId set Found = false set interGroupId = H2I( CreateGroupWJ() ) loop set EnumUnitId = H2I( FirstOfGroup( whichGroup ) ) exitwhen ( I2Unit( EnumUnitId ) == null ) call GroupRemoveUnit( whichGroup, I2Unit( EnumUnitId ) ) call GroupAddUnit( I2Group( interGroupId ), I2Unit( EnumUnitId ) ) set EnumUnitRange = DistanceByCoordinates( GetUnitX( I2Unit( EnumUnitId ) ), GetUnitY( I2Unit( EnumUnitId ) ), x, y ) if ( Found == false ) then set currentRange = EnumUnitRange set currentUnitId = EnumUnitId set Found = true elseif ( EnumUnitRange < currentRange ) then set currentRange = EnumUnitRange set currentUnitId = EnumUnitId endif endloop loop set EnumUnitId = H2I( FirstOfGroup( I2Group( interGroupId ) ) ) exitwhen ( I2Unit( EnumUnitId ) == null ) call GroupRemoveUnit( I2Group( interGroupId ), I2Unit( EnumUnitId ) ) call GroupAddUnit( whichGroup, I2Unit( EnumUnitId ) ) endloop call DestroyGroupWJ( I2Group( interGroupId ) ) return I2Unit( currentUnitId ) endfunction function GetUnitCurrentTarget takes unit whichUnit returns unit return I2Unit( GetAttachedInteger( H2I( whichUnit ), "Order_TargetId" ) ) endfunction function DispelUnit takes unit whichUnit, boolean positiveBuffs, boolean negativeBuffs returns nothing set udg_TempInteger[0] = H2I( whichUnit ) set udg_TempBoolean[0] = positiveBuffs set udg_TempBoolean[1] = negativeBuffs call ExecuteFunc( "Unit_is_dispelled" ) endfunction function IsUnitChanneling takes unit whichUnit returns boolean return false endfunction function UnitHasItemOfType takes unit whichUnit, integer whichTypeId returns boolean local integer iteration = 0 local integer inventorySize = UnitInventorySize( whichUnit ) loop exitwhen ( iteration >= inventorySize ) if ( GetItemTypeId( UnitItemInSlot( whichUnit, iteration ) ) == whichTypeId ) then return true endif set iteration = iteration + 1 endloop return false endfunction function SetUnitAbilityLevelWJ takes unit whichUnit, integer abilcode, integer level returns nothing if ( level > 0 ) then if ( GetUnitAbilityLevel( whichUnit, abilcode ) <= 0 ) then call UnitAddAbility( whichUnit, abilcode ) endif call SetUnitAbilityLevel( whichUnit, abilcode, level ) else call UnitRemoveAbility( whichUnit, abilcode ) endif endfunction function InitializeAbilityWJ takes integer abilcode returns nothing call SetUnitAbilityLevelWJ( udg_WorldCaster, abilcode, 1 ) call SetUnitAbilityLevelWJ( udg_WorldCaster, abilcode, 0 ) endfunction function UpdateUnitDisplay takes unit whichUnit returns nothing local integer newItemId = H2I( CreateItemWJ( UpdateUnitDisplay_ItemId(), 0, 0 ) ) if ( GetUnitAbilityLevel( whichUnit, HeroInventory_Id() ) <= 0 ) then call SetUnitAbilityLevelWJ( whichUnit, HeroInventory_Id(), 1 ) call UnitAddItem( whichUnit, I2Item( newItemId ) ) call SetUnitAbilityLevelWJ( whichUnit, HeroInventory_Id(), 0 ) endif call UnitAddItem( whichUnit, I2Item( newItemId ) ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Armor // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitArmor takes unit whichUnit, boolean bonus returns real if ( bonus ) then return GetAttachedReal( H2I( whichUnit ), "Armor_Bonus" ) endif return GetAttachedReal( H2I( whichUnit ), "Armor_Base" ) endfunction function SetUnitArmor takes unit whichUnit, real amount, boolean asBonus returns nothing if ( asBonus ) then call AttachReal( H2I( whichUnit ), "Armor_Bonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseArmor_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseArmor_Id(), -R2I( amount ) + 1 ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseArmor_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseArmor_Id(), R2I( amount ) + 1 ) endif else call AttachReal( H2I( whichUnit ), "Armor_Base", amount ) endif endfunction function AddUnitArmor takes unit whichUnit, real amount, boolean asBonus returns nothing call SetUnitArmor( whichUnit, GetUnitArmor( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitArmor_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Armor_RelativeBonus" ) endfunction function SetUnitArmor_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Armor_RelativeBonus", amount ) endfunction function AddUnitArmor_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitArmor_RelativeBonus( whichUnit, GetUnitArmor_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitArmor_BySpell_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Armor_BySpell_RelativeBonus" ) endfunction function SetUnitArmor_BySpell_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Armor_BySpell_RelativeBonus", amount ) endfunction function AddUnitArmor_BySpell_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitArmor_BySpell_RelativeBonus( whichUnit, GetUnitArmor_BySpell_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitArmor_Type takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "Armor_Type" ) endfunction function SetUnitArmor_Type takes unit whichUnit, integer whichArmorType returns nothing call AttachInteger( H2I( whichUnit ), "Armor_Type", whichArmorType ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Attack // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetAttackMultiplier takes integer whichDamageType, integer whichArmorType returns real if ( whichDamageType == 1 ) then if ( whichArmorType == 1 ) then return 1. elseif ( whichArmorType == 2 ) then return 1.5 elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 0.7 elseif ( whichArmorType == 5 ) then return 1. elseif ( whichArmorType == 6 ) then return 1. endif elseif ( whichDamageType == 2 ) then if ( whichArmorType == 1 ) then return 2. elseif ( whichArmorType == 2 ) then return 0.75 elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 0.35 elseif ( whichArmorType == 5 ) then return 0.5 elseif ( whichArmorType == 6 ) then return 1.5 endif elseif ( whichDamageType == 3 ) then if ( whichArmorType == 1 ) then return 1. elseif ( whichArmorType == 2 ) then return 0.5 elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 1.5 elseif ( whichArmorType == 5 ) then return 0.5 elseif ( whichArmorType == 6 ) then return 1.5 endif elseif ( whichDamageType == 4 ) then if ( whichArmorType == 1 ) then return 1.25 elseif ( whichArmorType == 2 ) then return 0.75 elseif ( whichArmorType == 3 ) then return 2. elseif ( whichArmorType == 4 ) then return 0.35 elseif ( whichArmorType == 5 ) then return 0.5 elseif ( whichArmorType == 6 ) then return 1. endif elseif ( whichDamageType == 5 ) then if ( whichArmorType == 1 ) then return 1. elseif ( whichArmorType == 2 ) then return 1. elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 1. elseif ( whichArmorType == 5 ) then return 1. elseif ( whichArmorType == 6 ) then return 1. endif elseif ( whichDamageType == 6 ) then if ( whichArmorType == 1 ) then return 1. elseif ( whichArmorType == 2 ) then return 1. elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 1. elseif ( whichArmorType == 5 ) then return 1. elseif ( whichArmorType == 6 ) then return 1. endif elseif ( whichDamageType == 7 ) then if ( whichArmorType == 1 ) then return 1. elseif ( whichArmorType == 2 ) then return 1. elseif ( whichArmorType == 3 ) then return 1. elseif ( whichArmorType == 4 ) then return 0.5 elseif ( whichArmorType == 5 ) then return 1. elseif ( whichArmorType == 6 ) then return 1. endif endif return 0. endfunction // DamageTypes // 1 - Normal // 2 - Pierce // 3 - Siege // 4 - Magic // 5 - Chaos // 6 - Spells // 7 - Hero // // ArmorTypes // 1 - Light // 2 - Medium // 3 - Heavy // 4 - Fort // 5 - Hero // 6 - Unarmored ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Blood // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitBlood takes unit whichUnit returns string return GetAttachedString( H2I( whichUnit ), "Blood" ) endfunction function SetUnitBlood takes unit whichUnit, string whichPath returns nothing call AttachString( H2I( whichUnit ), "Blood", whichPath ) endfunction function GetUnitBloodExplosion takes unit whichUnit returns string return GetAttachedString( H2I( whichUnit ), "BloodExplosion" ) endfunction function SetUnitBloodExplosion takes unit whichUnit, string whichPath returns nothing call AttachString( H2I( whichUnit ), "BloodExplosion", whichPath ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Break // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function HasUnitBreak takes unit whichUnit returns boolean return IsUnitPaused( whichUnit ) endfunction function SetUnitBreak takes unit whichUnit, boolean flag returns nothing call PauseUnit( whichUnit, flag ) endfunction function ResetUnitStun_Conditions0 takes integer whichUnitId returns boolean if ( I2Timer( GetAttachedInteger( whichUnitId, "StunTimer0Id" ) ) != null ) then return false endif if ( CountIntegersInTable( whichUnitId, "BondOfSouls_Casters" ) > 0 ) then return false endif return true endfunction function ResetUnitStun_Conditions1 takes integer whichUnitId returns boolean if ( I2Timer( GetAttachedInteger( whichUnitId, "StunTimer1Id" ) ) != null ) then return false endif return true endfunction function ResetUnitStun_Conditions2 takes integer whichUnitId returns boolean if ( I2Timer( GetAttachedInteger( whichUnitId, "StunTimer2Id" ) ) != null ) then return false endif return true endfunction function ResetUnitStun_Conditions takes integer whichUnitId, integer number returns boolean if ( number == 0 ) then return ResetUnitStun_Conditions0( whichUnitId ) elseif ( number == 1 ) then return ResetUnitStun_Conditions1( whichUnitId ) elseif ( number == 2 ) then return ResetUnitStun_Conditions2( whichUnitId ) endif return false endfunction function ResetUnitBreak_Conditions takes integer whichUnitId returns boolean if ( ResetUnitStun_Conditions0( whichUnitId ) == false ) then return false elseif ( ResetUnitStun_Conditions1( whichUnitId ) == false ) then return false elseif ( ResetUnitStun_Conditions2( whichUnitId ) == false ) then return false endif return true endfunction function ResetUnitBreak takes unit whichUnit returns nothing if ( ResetUnitBreak_Conditions( H2I( whichUnit ) ) ) then call SetUnitBreak( whichUnit, false ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Critical Strike // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function HasUnitCriticalStrikeProtection takes unit whichUnit returns boolean return GetAttachedBoolean( H2I( whichUnit ), "HasCriticalStrikeProtection" ) endfunction function ResetUnitCriticalStrikeProtection_Conditions takes unit whichUnit returns boolean if ( UnitHasItemOfType( whichUnit, HeartStone_Id() ) ) then return false endif return true endfunction function SetUnitCriticalStrikeProtection takes unit whichUnit, boolean flag returns nothing call AttachBoolean( H2I( whichUnit ), "HasCriticalStrikeProtection", flag ) endfunction function ResetUnitCriticalStrikeProtection takes unit whichUnit returns nothing if ( ResetUnitCriticalStrikeProtection_Conditions( whichUnit ) ) then call SetUnitCriticalStrikeProtection( whichUnit, false ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function HasUnitModifiedCriticalStrike takes unit whichUnit returns boolean return GetAttachedBoolean( H2I( whichUnit ), "HasCriticalStrikeProtection" ) endfunction function ResetUnitModifiedCriticalStrike_Conditions takes unit whichUnit returns boolean if ( GetUnitAbilityLevel( whichUnit, AxeMaster_Id() ) > 0 ) then return false endif return true endfunction function SetUnitModifiedCriticalStrike takes unit whichUnit, boolean flag returns nothing call AttachBoolean( H2I( whichUnit ), "HasModifiedCriticalStrike", flag ) endfunction function ResetUnitModifiedCriticalStrike takes unit whichUnit returns nothing if ( ResetUnitModifiedCriticalStrike_Conditions( whichUnit ) ) then call SetUnitModifiedCriticalStrike( whichUnit, false ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Drop // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDrop_ByDeath takes unit whichUnit, boolean bonus returns integer if ( bonus ) then return GetAttachedInteger( H2I( whichUnit ), "Drop_ByDeath_Bonus" ) endif return GetAttachedInteger( H2I( whichUnit ), "Drop_ByDeath_Base" ) endfunction function SetUnitDrop_ByDeath takes unit whichUnit, integer amount, boolean asBonus returns nothing if ( asBonus ) then call AttachInteger( H2I( whichUnit ), "Drop_ByDeath_Bonus", amount ) else call AttachInteger( H2I( whichUnit ), "Drop_ByDeath_Base", amount ) endif endfunction function AddUnitDrop_ByDeath takes unit whichUnit, integer amount, boolean asBonus returns nothing call SetUnitDrop_ByDeath( whichUnit, GetUnitDrop_ByDeath( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDrop_ByDeath_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Drop_ByDeath_RelativeBonus" ) endfunction function SetUnitDrop_ByDeath_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Drop_ByDeath_RelativeBonus", amount ) endfunction function AddUnitDrop_ByDeath_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitDrop_ByDeath_RelativeBonus( whichUnit, GetUnitDrop_ByDeath_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDrop_ByKill takes unit whichUnit, boolean bonus returns integer if ( bonus ) then return GetAttachedInteger( H2I( whichUnit ), "Drop_ByKill_Bonus" ) endif return GetAttachedInteger( H2I( whichUnit ), "Drop_ByKill_Base" ) endfunction function SetUnitDrop_ByKill takes unit whichUnit, integer amount, boolean asBonus returns nothing if ( asBonus ) then call AttachInteger( H2I( whichUnit ), "Drop_ByKill_Bonus", amount ) else call AttachInteger( H2I( whichUnit ), "Drop_ByKill_Base", amount ) endif endfunction function AddUnitDrop_ByKill takes unit whichUnit, integer amount, boolean asBonus returns nothing call SetUnitDrop_ByKill( whichUnit, GetUnitDrop_ByKill( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDrop_ByKill_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Drop_ByKill_RelativeBonus" ) endfunction function SetUnitDrop_ByKill_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Drop_ByKill_RelativeBonus", amount ) endfunction function AddUnitDrop_ByKill_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitDrop_ByKill_RelativeBonus( whichUnit, GetUnitDrop_ByKill_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetAttackDrop takes unit Victim, unit Attacker returns integer return R2I( ( GetUnitDrop_ByKill( Attacker, false ) + GetUnitDrop_ByDeath( Victim, false ) ) * ( 1 + GetUnitDrop_ByKill_RelativeBonus( Attacker ) - GetUnitDrop_ByDeath_RelativeBonus( Victim ) ) + GetUnitDrop_ByKill( Attacker, true ) + GetUnitDrop_ByDeath( Victim, true ) ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function UnitDamageUnitEx takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns nothing local boolean causesDeath local integer targetId = H2I( target ) local integer TriggerId = GetSavedInteger( "MainTriggers", "Unit_takes_Damage" ) call DisableTrigger( I2Trigger( TriggerId ) ) if ( GetAttachedBoolean( targetId, "DoesNotDie" ) ) then set causesDeath = ( amount >= GetUnitState( target, UNIT_STATE_LIFE ) - LimitOfDeath() - LimitOfImmortals() ) call UnitDamageTarget( whichUnit, target, LimitOfImmortals(), attack, ranged, attackType, damageType, weaponType ) else set causesDeath = ( amount >= GetUnitState( target, UNIT_STATE_LIFE ) - LimitOfDeath() ) call UnitDamageTarget( whichUnit, target, amount, attack, ranged, attackType, damageType, weaponType ) if ( ( causesDeath ) and ( whichUnit != null ) ) then if ( IsUnitEnemy( whichUnit, GetOwningPlayer( target ) ) ) then if ( GetAttackDrop( target, whichUnit ) > GetUnitDrop_ByDeath( target, false ) ) then call SetPlayerState( GetOwningPlayer( target ), PLAYER_STATE_GIVES_BOUNTY, 0 ) endif endif endif endif call EnableTrigger( I2Trigger( TriggerId ) ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Damage // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage takes unit whichUnit, boolean bonus returns real if ( bonus ) then return GetAttachedReal( H2I( whichUnit ), "Damage_Bonus" ) endif return GetAttachedReal( H2I( whichUnit ), "Damage_Base" ) endfunction function SetUnitDamage takes unit whichUnit, real amount, boolean asBonus returns nothing local integer DamagePacket local integer DamagePacketLevel local boolean HasHeroInventory local real PreviousBaseDamage if ( asBonus ) then call AttachReal( H2I( whichUnit ), "Damage_Bonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseDamage_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseDamage_Id(), -R2I( amount ) + 1 ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseDamage_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseDamage_Id(), R2I( amount ) + 1 ) endif else set DamagePacketLevel = 7 set HasHeroInventory = ( GetUnitAbilityLevel( whichUnit, HeroInventory_Id() ) > 0 ) set PreviousBaseDamage = GetUnitDamage( whichUnit, false ) call AttachReal( H2I( whichUnit ), "Damage_Base", amount ) set amount = amount - PreviousBaseDamage if ( HasHeroInventory == false ) then call SetUnitAbilityLevelWJ( whichUnit, HeroInventory_Id(), 1 ) endif if ( amount < 0 ) then set amount = -amount set DamagePacket = 64 loop exitwhen ( amount < 1 ) loop exitwhen ( amount < DamagePacket ) call UnitAddItem( whichUnit, CreateItemWJ( GetSavedInteger( "Damage_DecreaseAttackDamage", I2S( DamagePacketLevel ) ), 0, 0 ) ) set amount = amount - DamagePacket endloop set DamagePacket = DamagePacket / 2 set DamagePacketLevel = DamagePacketLevel - 1 endloop else set DamagePacket = 64 loop exitwhen ( amount < 1 ) loop exitwhen ( amount < DamagePacket ) call UnitAddItem( whichUnit, CreateItemWJ( GetSavedInteger( "Damage_IncreaseAttackDamage", I2S( DamagePacketLevel ) ), 0, 0 ) ) set amount = amount - DamagePacket endloop set DamagePacket = DamagePacket / 2 set DamagePacketLevel = DamagePacketLevel - 1 endloop endif if ( HasHeroInventory == false ) then call SetUnitAbilityLevelWJ( whichUnit, HeroInventory_Id(), 0 ) endif endif endfunction function AddUnitDamage takes unit whichUnit, real amount, boolean asBonus returns nothing call SetUnitDamage( whichUnit, GetUnitDamage( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage_Dices_Amount takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "Damage_Dices_Amount" ) endfunction function SetUnitDamage_Dices_Amount takes unit whichUnit, integer amount returns nothing call AttachInteger( H2I( whichUnit ), "Damage_Dices_Amount", amount ) endfunction function AddUnitDamage_Dices_Amount takes unit whichUnit, integer amount returns nothing call SetUnitDamage_Dices_Amount( whichUnit, GetUnitDamage_Dices_Amount( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage_Dices_Sides takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "Damage_Dices_Sides" ) endfunction function SetUnitDamage_Dices_Sides takes unit whichUnit, integer amount returns nothing call AttachInteger( H2I( whichUnit ), "Damage_Dices_Sides", amount ) endfunction function AddUnitDamage_Dices_Sides takes unit whichUnit, integer amount returns nothing call SetUnitDamage_Dices_Sides( whichUnit, GetUnitDamage_Dices_Sides( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Damage_RelativeBonus" ) endfunction function SetUnitDamage_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Damage_RelativeBonus", amount ) endfunction function AddUnitDamage_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitDamage_RelativeBonus( whichUnit, GetUnitDamage_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage_BySpell_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "Damage_BySpell_RelativeBonus" ) endfunction function SetUnitDamage_BySpell_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "Damage_BySpell_RelativeBonus", amount ) endfunction function AddUnitDamage_BySpell_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitDamage_BySpell_RelativeBonus( whichUnit, GetUnitDamage_BySpell_RelativeBonus( whichUnit ) + amount ) endfunction function UnitDamageUnitBySpell takes unit whichUnit, unit target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns nothing call UnitDamageUnitEx( whichUnit, target, amount * ( 1 + GetUnitDamage_BySpell_RelativeBonus( whichUnit ) - GetUnitArmor_BySpell_RelativeBonus( target ) ), attack, ranged, attackType, damageType, weaponType ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitDamage_Type takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "Damage_Type" ) endfunction function SetUnitDamage_Type takes unit whichUnit, integer whichDamageType returns nothing call AttachInteger( H2I( whichUnit ), "Damage_Type", whichDamageType ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Max Life // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitLifeMax takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "LifeMax" ) endfunction function SetUnitLifeMax takes unit whichUnit, integer amount returns nothing local integer LifeMaxPacket local integer LifeMaxPacketLevel = 12 local integer PreviousLifeMax = GetUnitLifeMax( whichUnit ) call AttachInteger( H2I( whichUnit ), "LifeMax", amount ) set amount = amount - PreviousLifeMax if ( amount < 0 ) then set amount = -amount set LifeMaxPacket = 1024 loop exitwhen ( amount == 0 ) loop exitwhen ( amount < LifeMaxPacket ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseLifeMax_Id(), LifeMaxPacketLevel ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseLifeMax_Id(), 0 ) set amount = amount - LifeMaxPacket endloop set LifeMaxPacket = LifeMaxPacket / 2 set LifeMaxPacketLevel = LifeMaxPacketLevel - 1 endloop else set LifeMaxPacket = 1024 loop exitwhen ( amount == 0 ) loop exitwhen ( amount < LifeMaxPacket ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseLifeMax_Id(), LifeMaxPacketLevel ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseLifeMax_Id(), 0 ) set amount = amount - LifeMaxPacket endloop set LifeMaxPacket = LifeMaxPacket / 2 set LifeMaxPacketLevel = LifeMaxPacketLevel - 1 endloop endif endfunction function AddUnitLifeMax takes unit whichUnit, integer amount returns nothing call SetUnitLifeMax( whichUnit, GetUnitLifeMax( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Max Mana // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitManaMax takes unit whichUnit returns integer return GetAttachedInteger( H2I( whichUnit ), "ManaMax" ) endfunction function SetUnitManaMax takes unit whichUnit, integer amount returns nothing local integer ManaMaxPacket local integer ManaMaxPacketLevel = 12 local integer PreviousManaMax = GetUnitManaMax( whichUnit ) call AttachInteger( H2I( whichUnit ), "ManaMax", amount ) set amount = amount - PreviousManaMax if ( amount < 0 ) then set amount = -amount set ManaMaxPacket = 1024 loop exitwhen ( amount == 0 ) loop exitwhen ( amount < ManaMaxPacket ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseManaMax_Id(), ManaMaxPacketLevel ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseManaMax_Id(), 0 ) set amount = amount - ManaMaxPacket endloop set ManaMaxPacket = ManaMaxPacket / 2 set ManaMaxPacketLevel = ManaMaxPacketLevel - 1 endloop else set ManaMaxPacket = 1024 loop exitwhen ( amount == 0 ) loop exitwhen ( amount < ManaMaxPacket ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseManaMax_Id(), ManaMaxPacketLevel ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseManaMax_Id(), 0 ) set amount = amount - ManaMaxPacket endloop set ManaMaxPacket = ManaMaxPacket / 2 set ManaMaxPacketLevel = ManaMaxPacketLevel - 1 endloop endif endfunction function AddUnitManaMax takes unit whichUnit, integer amount returns nothing call SetUnitManaMax( whichUnit, GetUnitManaMax( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Hero Attributes // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitAgility takes unit whichUnit, boolean bonus returns integer if ( bonus ) then return GetAttachedInteger( H2I( whichUnit ), "Agility_Bonus" ) endif return GetAttachedInteger( H2I( whichUnit ), "Agility_Base" ) endfunction function SetUnitAgility takes unit whichUnit, integer amount, boolean asBonus returns nothing local integer PreviousAgility = GetUnitAgility( whichUnit, asBonus ) local integer PrimaryAttribute = GetAttachedInteger( GetUnitTypeId( whichUnit ), "PrimaryAttribute" ) if ( asBonus ) then call AttachInteger( H2I( whichUnit ), "Agility_Bonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseAgility_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseAgility_Id(), -amount + 1 ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseAgility_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseAgility_Id(), amount + 1 ) endif else call AttachInteger( H2I( whichUnit ), "Agility_Base", amount ) call SetHeroAgi( whichUnit, amount, true ) endif set amount = amount - PreviousAgility call AddUnitArmor( whichUnit, amount * ArmorBonusPerAgilityPoint(), asBonus ) if ( PrimaryAttribute == 2 ) then call AddUnitDamage( whichUnit, amount * DamageBonusPerPrimaryAttributePoint(), asBonus ) endif endfunction function AddUnitAgility takes unit whichUnit, integer amount, boolean asBonus returns nothing call SetUnitAgility( whichUnit, GetUnitAgility( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitIntelligence takes unit whichUnit, boolean bonus returns integer if ( bonus ) then return GetAttachedInteger( H2I( whichUnit ), "Intelligence_Bonus" ) endif return GetAttachedInteger( H2I( whichUnit ), "Intelligence_Base" ) endfunction function SetUnitIntelligence takes unit whichUnit, integer amount, boolean asBonus returns nothing local integer PreviousIntelligence = GetUnitIntelligence( whichUnit, asBonus ) local integer PrimaryAttribute = GetAttachedInteger( GetUnitTypeId( whichUnit ), "PrimaryAttribute" ) if ( asBonus ) then call AttachInteger( H2I( whichUnit ), "Intelligence_Bonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseIntelligence_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseIntelligence_Id(), -amount + 1 ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseIntelligence_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseIntelligence_Id(), amount + 1 ) endif else call AttachInteger( H2I( whichUnit ), "Intelligence_Base", amount ) call SetHeroInt( whichUnit, amount, true ) endif set amount = amount - PreviousIntelligence call AddUnitManaMax( whichUnit, amount * ManaMaxBonusPerIntelligencePoint() ) if ( PrimaryAttribute == 3 ) then call AddUnitDamage( whichUnit, amount * DamageBonusPerPrimaryAttributePoint(), asBonus ) endif endfunction function AddUnitIntelligence takes unit whichUnit, integer amount, boolean asBonus returns nothing call SetUnitIntelligence( whichUnit, GetUnitIntelligence( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitStrength takes unit whichUnit, boolean bonus returns integer if ( bonus ) then return GetAttachedInteger( H2I( whichUnit ), "Strength_Bonus" ) endif return GetAttachedInteger( H2I( whichUnit ), "Strength_Base" ) endfunction function SetUnitStrength takes unit whichUnit, integer amount, boolean asBonus returns nothing local integer PreviousStrength = GetUnitStrength( whichUnit, asBonus ) local integer PrimaryAttribute = GetAttachedInteger( GetUnitTypeId( whichUnit ), "PrimaryAttribute" ) if ( asBonus ) then call AttachInteger( H2I( whichUnit ), "Strength_Bonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseStrength_Id(), 1 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseStrength_Id(), -amount + 1 ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseStrength_Id(), 0 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseStrength_Id(), amount + 1 ) endif else call AttachInteger( H2I( whichUnit ), "Strength_Base", amount ) call SetHeroStr( whichUnit, amount, true ) endif set amount = amount - PreviousStrength call AddUnitLifeMax( whichUnit, amount * LifeMaxBonusPerStrengthPoint() ) if ( PrimaryAttribute == 1 ) then call AddUnitDamage( whichUnit, amount * DamageBonusPerPrimaryAttributePoint(), asBonus ) endif endfunction function AddUnitStrength takes unit whichUnit, integer amount, boolean asBonus returns nothing call SetUnitStrength( whichUnit, GetUnitStrength( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Evade // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitEvadeChance takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "EvadeChance" ) endfunction function SetUnitEvadeChance takes unit whichUnit, real chance returns nothing call AttachReal( H2I( whichUnit ), "EvadeChance", chance ) call SetUnitAbilityLevelWJ( whichUnit, ModifyEvadeChance_Id(), R2I( chance * 100 ) + 1 ) endfunction function AddUnitEvadeChance takes unit whichUnit, real chance returns nothing call SetUnitEvadeChance( whichUnit, GetUnitEvadeChance( whichUnit ) + chance ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Pathing // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function SetUnitPathingWJ takes unit whichUnit, boolean flag returns nothing call SetUnitPathing( whichUnit, flag ) endfunction function ResetUnitPathing_Conditions takes integer whichUnitId returns boolean if ( I2Timer( GetAttachedInteger( whichUnitId, "StonesThrow_UpdateTimerId" ) ) != null ) then return false endif if ( I2Timer( GetAttachedInteger( whichUnitId, "Whirlwind_DurationTimerId" ) ) != null ) then return false endif return true endfunction function ResetUnitPathing takes unit whichUnit returns nothing if ( ResetUnitPathing_Conditions( H2I( whichUnit ) ) ) then call SetUnitPathingWJ( whichUnit, true ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Scaling // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitScaleX takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "ScaleX" ) endfunction function GetUnitScaleY takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "ScaleY" ) endfunction function GetUnitScaleZ takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "ScaleZ" ) endfunction function SetUnitScaleWJ takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing local integer whichUnitId = H2I( whichUnit ) call AttachReal( whichUnitId, "ScaleX", scaleX ) call AttachReal( whichUnitId, "ScaleY", scaleY ) call AttachReal( whichUnitId, "ScaleZ", scaleZ ) call SetUnitScale( whichUnit, scaleX, scaleY, scaleZ ) endfunction function AddUnitScale takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing call SetUnitScaleWJ( whichUnit, GetUnitScaleX( whichUnit ) + scaleX, GetUnitScaleY( whichUnit ) + scaleY, GetUnitScaleZ( whichUnit ) + scaleZ ) endfunction function AddUnitScaleTimed_Ending takes integer DurationTimerId returns nothing local integer IntervalTimerId = GetAttachedInteger( DurationTimerId, "IntervalTimerId" ) local integer whichUnitId = GetAttachedInteger( DurationTimerId, "whichUnitId" ) call FlushAttachedInteger( DurationTimerId, "IntervalTimerId" ) call FlushAttachedInteger( DurationTimerId, "whichUnitId" ) call DestroyTimerWJ( I2Timer( DurationTimerId ) ) call FlushAttachedReal( IntervalTimerId, "Duration" ) call FlushAttachedInteger( IntervalTimerId, "DurationTimerId" ) call FlushAttachedInteger( IntervalTimerId, "whichUnitId" ) call FlushAttachedReal( IntervalTimerId, "XBonus" ) call FlushAttachedReal( IntervalTimerId, "YBonus" ) call FlushAttachedReal( IntervalTimerId, "ZBonus" ) call DestroyTimerWJ( I2Timer( IntervalTimerId ) ) call RemoveIntegerFromTable( whichUnitId, "Scale_DurationTimers", DurationTimerId ) endfunction function AddUnitScaleTimed_EndingByTimer takes nothing returns nothing local integer DurationTimerId = H2I( GetExpiredTimer() ) call AddUnitScaleTimed_Ending( DurationTimerId ) endfunction function AddUnitScaleTimed_Child takes nothing returns nothing local integer IntervalTimerId = H2I( GetExpiredTimer() ) local real duration = GetAttachedReal( IntervalTimerId, "Duration" ) local integer DurationTimerId = GetAttachedInteger( IntervalTimerId, "DurationTimerId" ) local integer whichUnitId = GetAttachedInteger( DurationTimerId, "whichUnitId" ) call AddUnitScale( I2Unit( whichUnitId ), GetAttachedReal( IntervalTimerId, "XBonus" ), GetAttachedReal( IntervalTimerId, "YBonus" ), GetAttachedReal( IntervalTimerId, "ZBonus" ) ) endfunction function AddUnitScaleTimed takes unit whichUnit, real scaleX, real scaleY, real scaleZ, real duration returns nothing local integer whichUnitId = H2I( whichUnit ) local integer DurationTimerId = H2I( CreateTimerWJ() ) local integer IntervalTimerId = H2I( CreateTimerWJ() ) call AttachInteger( DurationTimerId, "IntervalTimerId", IntervalTimerId ) call AttachInteger( DurationTimerId, "whichUnitId", whichUnitId ) call AttachReal( IntervalTimerId, "Duration", duration ) call AttachInteger( IntervalTimerId, "DurationTimerId", DurationTimerId ) call AttachReal( IntervalTimerId, "XBonus", scaleX * 0.01 / duration ) call AttachReal( IntervalTimerId, "YBonus", scaleY * 0.01 / duration ) call AttachReal( IntervalTimerId, "ZBonus", scaleZ * 0.01 / duration ) call AddIntegerToTable( whichUnitId, "Scale_DurationTimers", DurationTimerId ) call TimerStart( I2Timer( IntervalTimerId ), 0.01, true, function AddUnitScaleTimed_Child ) call TimerStart( I2Timer( DurationTimerId ), duration, false, function AddUnitScaleTimed_EndingByTimer ) endfunction function ResetUnitScale takes unit whichUnit returns nothing local integer whichUnitId = H2I( whichUnit ) local integer whichUnitTypeId = GetUnitTypeId( whichUnit ) if ( CountIntegersInTable( whichUnitId, "ScaleFadeTimers" ) == 0 ) then call SetUnitScaleWJ( whichUnit, GetAttachedReal( whichUnitTypeId, "ScaleX" ), GetAttachedReal( whichUnitTypeId, "ScaleY" ), GetAttachedReal( whichUnitTypeId, "ScaleZ" ) ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Silence // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function IsUnitSilenced takes unit whichUnit returns boolean return ( GetUnitAbilityLevel( whichUnit, Silence_BuffId() ) > 0 ) endfunction function SetUnitSilence takes unit whichUnit, boolean flag returns nothing if ( flag ) then //call BJDebugMsg( B2S( IssueTargetOrderById( udg_WorldCaster, Silence_OrderId(), whichUnit ) ) ) else call SetUnitAbilityLevelWJ( whichUnit, Silence_BuffId(), 0 ) endif endfunction function ResetUnitSilence_Conditions takes integer whichUnitId returns boolean if ( I2Timer( GetAttachedInteger( whichUnitId, "StonesThrow_UpdateTimerId" ) ) != null ) then return false endif if ( IsUnitInGroup( I2Unit( whichUnitId ), I2Group( GetAttachedInteger( TonelessMist_Id(), "TargetGroupId" ) ) ) ) then return false endif return true endfunction function ResetUnitSilence takes unit whichUnit returns nothing if ( ResetUnitSilence_Conditions( H2I( whichUnit ) ) ) then call SetUnitSilence( whichUnit, false ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Attack Rate // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitAttackRate_RelativeBonus takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "AttackRate_RelativeBonus" ) endfunction function SetUnitAttackRate_RelativeBonus takes unit whichUnit, real amount returns nothing call AttachReal( H2I( whichUnit ), "AttackRate_RelativeBonus", amount ) if ( amount < 0 ) then call SetUnitAbilityLevelWJ( whichUnit, IncreaseAttackRate_Id(), 0 ) call SetUnitAbilityLevelWJ( whichUnit, DecreaseAttackRate_Id(), R2I( amount * 100 ) ) else call SetUnitAbilityLevelWJ( whichUnit, DecreaseAttackRate_Id(), 0 ) call SetUnitAbilityLevelWJ( whichUnit, IncreaseAttackRate_Id(), R2I( amount * 100 ) ) endif endfunction function AddUnitAttackRate_RelativeBonus takes unit whichUnit, real amount returns nothing call SetUnitAttackRate_RelativeBonus( whichUnit, GetUnitAttackRate_RelativeBonus( whichUnit ) + amount ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Speed // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitSpeed takes unit whichUnit, boolean bonus returns real if ( bonus ) then return GetAttachedReal( H2I( whichUnit ), "Speed_Bonus" ) endif return GetAttachedReal( H2I( whichUnit ), "Speed_Base" ) endfunction function SetUnitSpeed takes unit whichUnit, real amount, boolean asBonus returns nothing if ( asBonus ) then call AttachReal( H2I( whichUnit ), "Speed_Bonus", amount ) call SetUnitAbilityLevelWJ( whichUnit, ModifyMoveSpeed_Id(), 2 + Sign( amount ) ) call UpdateUnitDisplay( whichUnit ) else call AttachReal( H2I( whichUnit ), "Speed_Base", amount ) endif call SetUnitMoveSpeed( whichUnit, GetUnitSpeed( whichUnit, not( asBonus ) ) + amount - Sign( GetUnitSpeed( whichUnit, true ) ) ) endfunction function AddUnitSpeed takes unit whichUnit, real amount, boolean asBonus returns nothing call SetUnitSpeed( whichUnit, GetUnitSpeed( whichUnit, asBonus ) + amount, asBonus ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Stun // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function HasUnitStun takes unit whichUnit, integer number returns boolean return GetAttachedBoolean( H2I( whichUnit ), "HasStun" + I2S( number ) ) endfunction function SetUnitStun_Child takes integer whichUnitId, integer number, boolean flag returns nothing if ( flag ) then if ( number == 0 ) then call SetUnitBreak( I2Unit( whichUnitId ), true ) elseif ( number == 1 ) then call SetUnitBreak( I2Unit( whichUnitId ), true ) elseif ( number == 2 ) then call SetUnitBreak( I2Unit( whichUnitId ), true ) endif else if ( number == 0 ) then call ResetUnitBreak( I2Unit( whichUnitId ) ) elseif ( number == 1 ) then call ResetUnitBreak( I2Unit( whichUnitId ) ) elseif ( number == 2 ) then call ResetUnitBreak( I2Unit( whichUnitId ) ) endif endif endfunction function SetUnitStun takes unit whichUnit, integer number, boolean flag returns nothing local integer whichUnitId = H2I( whichUnit ) local integer GraphicwhichUnitId = GetAttachedInteger( whichUnitId, "Stun_Graphic" + I2S( number ) + "Id" ) local string Graphic local string GraphicAttachmentPoint local integer StunTimerId if ( I2Effect( GraphicwhichUnitId ) != null ) then call DestroyEffectWJ( I2Effect( GraphicwhichUnitId ) ) if ( flag == false ) then call FlushAttachedInteger( whichUnitId, "Stun_Graphic" + I2S( number ) + "Id" ) endif endif if ( flag ) then set Graphic = GetSavedString( "Stun_Graphic", I2S( number ) ) if ( StringLength( Graphic ) > 0 ) then set GraphicAttachmentPoint = GetSavedString( "Stun_GraphicAttachmentPoint", I2S( number ) ) if ( StringLength( GraphicAttachmentPoint ) > 0 ) then call AttachInteger( whichUnitId, "Stun_Graphic" + I2S( number ) + "Id", H2I( AddSpecialEffectTargetWJ( GetSavedString( "Stun_Graphic", I2S( number ) ), whichUnit, GetSavedString( "Stun_GraphicAttachmentPoint", I2S( number ) ) ) ) ) endif endif else set StunTimerId = GetAttachedInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id" ) if ( I2Timer( StunTimerId ) != null ) then call FlushAttachedInteger( StunTimerId, "Number" ) call FlushAttachedInteger( StunTimerId, "whichUnitId" ) call FlushAttachedInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id" ) call DestroyTimerWJ( I2Timer( StunTimerId ) ) endif endif if ( flag != HasUnitStun( whichUnit, number ) ) then call AttachBoolean( whichUnitId, "HasStun" + I2S( number ), flag ) call SetUnitStun_Child( whichUnitId, number, flag ) endif endfunction function ResetUnitStun takes unit whichUnit, integer number returns nothing if ( ResetUnitStun_Conditions( H2I( whichUnit ), number ) ) then call SetUnitStun( whichUnit, number, false ) endif endfunction function SetUnitStunTimed_Child takes nothing returns nothing local integer StunTimerId = H2I( GetExpiredTimer() ) local integer number = GetAttachedInteger( StunTimerId, "Number" ) local integer whichUnitId = GetAttachedInteger( StunTimerId, "whichUnitId" ) call FlushAttachedInteger( StunTimerId, "Number" ) call FlushAttachedInteger( StunTimerId, "whichUnitId" ) call DestroyTimerWJ( I2Timer( StunTimerId ) ) call FlushAttachedInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id" ) call ResetUnitStun( I2Unit( whichUnitId ), number ) endfunction function SetUnitStunTimed takes unit whichUnit, integer number, real duration returns nothing local integer whichUnitId = H2I( whichUnit ) local integer StunTimerId = GetAttachedInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id" ) call SetUnitStun( whichUnit, number, true ) if ( I2Timer( StunTimerId ) == null ) then set StunTimerId = H2I( CreateTimerWJ() ) call AttachInteger( StunTimerId, "Number", number ) call AttachInteger( StunTimerId, "whichUnitId", whichUnitId ) call AttachInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id", StunTimerId ) endif if ( duration > TimerGetRemaining( I2Timer( StunTimerId ) ) ) then call TimerStart( I2Timer( StunTimerId ), duration, false, function SetUnitStunTimed_Child ) endif endfunction function BreakUnitStun_Child0 takes integer whichUnitId returns nothing local integer CasterId set udg_TempInteger[0] = whichUnitId call ExecuteFunc( "BondOfSouls_Death_Executed" ) endfunction function BreakUnitStun_Child1 takes integer whichUnitId returns nothing endfunction function BreakUnitStun_Child2 takes integer whichUnitId returns nothing endfunction function BreakUnitStun takes unit whichUnit, integer number returns nothing local integer whichUnitId = H2I( whichUnit ) local integer StunTimerId = GetAttachedInteger( whichUnitId, "StunTimer" + I2S( number ) + "Id" ) if ( I2Timer( StunTimerId ) != null ) then call FlushAttachedInteger( StunTimerId, "Number" ) call FlushAttachedInteger( StunTimerId, "whichUnitId" ) call FlushAttachedInteger( whichUnitId, "StunTimer2Id" ) call DestroyTimerWJ( I2Timer( StunTimerId ) ) endif if ( number == 0 ) then call BreakUnitStun_Child0( whichUnitId ) elseif ( number == 1 ) then call BreakUnitStun_Child1( whichUnitId ) elseif ( number == 2 ) then call BreakUnitStun_Child2( whichUnitId ) endif call SetUnitStun( whichUnit, number, false ) endfunction ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Vertex Color // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitVertexColorRed takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "VertexColorRed" ) endfunction function GetUnitVertexColorGreen takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "VertexColorGreen" ) endfunction function GetUnitVertexColorBlue takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "VertexColorBlue" ) endfunction function GetUnitVertexColorAlpha takes unit whichUnit returns real return GetAttachedReal( H2I( whichUnit ), "VertexColorAlpha" ) endfunction function SetUnitVertexColorWJ takes unit whichUnit, real red, real green, real blue, real alpha returns nothing if ( red < 0 ) then set red = 0 elseif ( red > 255 ) then set red = 255 endif if ( green < 0 ) then set green = 0 elseif ( green > 255 ) then set green = 255 endif if ( blue < 0 ) then set blue = 0 elseif ( blue > 255 ) then set blue = 255 endif if ( alpha < 0 ) then set alpha = 0 elseif ( alpha > 255 ) then set alpha = 255 endif call SetUnitVertexColor( whichUnit, R2I( red ), R2I( green ), R2I( blue ), R2I( alpha ) ) endfunction function SetUnitVertexColorEx takes unit whichUnit, real red, real green, real blue, real alpha returns nothing local integer whichUnitId = H2I( whichUnit ) call AttachReal( whichUnitId, "VertexColorRed", red ) call AttachReal( whichUnitId, "VertexColorGreen", green ) call AttachReal( whichUnitId, "VertexColorBlue", blue ) call AttachReal( whichUnitId, "VertexColorAlpha", alpha ) call SetUnitVertexColorWJ( whichUnit, R2I( red ), R2I( green ), R2I( blue ), R2I( alpha ) ) endfunction function AddUnitVertexColor takes unit whichUnit, real red, real green, real blue, real alpha returns nothing call SetUnitVertexColorEx( whichUnit, GetUnitVertexColorRed( whichUnit ) + red, GetUnitVertexColorGreen( whichUnit ) + green, GetUnitVertexColorBlue( whichUnit ) + blue, GetUnitVertexColorAlpha( whichUnit ) + alpha ) endfunction function AddUnitVertexColorTimed_Ending takes integer DurationTimerId returns nothing local integer FadeTimerId = GetAttachedInteger( DurationTimerId, "FadeTimerId" ) local integer whichUnitId = GetAttachedInteger( DurationTimerId, "whichUnitId" ) call FlushAttachedInteger( DurationTimerId, "FadeTimerId" ) call FlushAttachedInteger( DurationTimerId, "whichUnitId" ) call DestroyTimerWJ( I2Timer( DurationTimerId ) ) call FlushAttachedInteger( FadeTimerId, "DurationTimerId" ) call FlushAttachedReal( FadeTimerId, "RedBonus" ) call FlushAttachedReal( FadeTimerId, "GreenBonus" ) call FlushAttachedReal( FadeTimerId, "BlueBonus" ) call FlushAttachedReal( FadeTimerId, "AlphaBonus" ) call DestroyTimerWJ( I2Timer( FadeTimerId ) ) call RemoveIntegerFromTable( whichUnitId, "VertexColor_DurationTimers", DurationTimerId ) endfunction function AddUnitVertexColorTimed_EndingByTimer takes nothing returns nothing local integer DurationTimerId = H2I( GetExpiredTimer() ) call AddUnitVertexColorTimed_Ending( DurationTimerId ) endfunction function AddUnitVertexColorTimed_Child takes nothing returns nothing local integer FadeTimerId = H2I( GetExpiredTimer() ) local integer DurationTimerId = GetAttachedInteger( FadeTimerId, "DurationTimerId" ) local integer whichUnitId = GetAttachedInteger( DurationTimerId, "whichUnitId" ) call AddUnitVertexColor( I2Unit( whichUnitId ), GetAttachedReal( FadeTimerId, "RedBonus" ), GetAttachedReal( FadeTimerId, "GreenBonus" ), GetAttachedReal( FadeTimerId, "BlueBonus" ), GetAttachedReal( FadeTimerId, "AlphaBonus" ) ) endfunction function AddUnitVertexColorTimed takes unit whichUnit, real red, real green, real blue, real alpha, real duration returns nothing local integer DurationTimerId local integer FadeTimerId local integer whichUnitId if ( duration != 0 ) then set DurationTimerId = H2I( CreateTimerWJ() ) set FadeTimerId = H2I( CreateTimerWJ() ) set whichUnitId = H2I( whichUnit ) call AttachInteger( DurationTimerId, "FadeTimerId", FadeTimerId ) call AttachInteger( DurationTimerId, "whichUnitId", whichUnitId ) call AttachInteger( FadeTimerId, "DurationTimerId", DurationTimerId ) call AttachReal( FadeTimerId, "RedBonus", red * 0.01 / duration ) call AttachReal( FadeTimerId, "GreenBonus", green * 0.01 / duration ) call AttachReal( FadeTimerId, "BlueBonus", blue * 0.01 / duration ) call AttachReal( FadeTimerId, "AlphaBonus", alpha * 0.01 / duration ) call AddIntegerToTable( whichUnitId, "VertexColor_DurationTimers", DurationTimerId ) call TimerStart( I2Timer( FadeTimerId ), 0.01, true, function AddUnitVertexColorTimed_Child ) call TimerStart( I2Timer( DurationTimerId ), duration, false, function AddUnitVertexColorTimed_EndingByTimer ) endif endfunction function ResetUnitVertexColor takes unit whichUnit returns nothing local integer whichUnitId = H2I( whichUnit ) local integer whichUnitTypeId = GetUnitTypeId( whichUnit ) if ( CountIntegersInTable( whichUnitId, "VertexColor_DurationTimers" ) == 0 ) then call SetUnitVertexColorEx( whichUnit, GetAttachedReal( whichUnitTypeId, "VertexColorRed" ), GetAttachedReal( whichUnitTypeId, "VertexColorGreen" ), GetAttachedReal( whichUnitTypeId, "VertexColorBlue" ), GetAttachedReal( whichUnitTypeId, "VertexColorAlpha" ) ) endif endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Weapon Type // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function GetUnitWeaponType takes unit whichUnit returns weapontype return I2WeaponType( GetAttachedInteger( H2I( whichUnit ), "WeaponType" ) ) endfunction function SetUnitWeaponType takes unit whichUnit, weapontype whichWeaponType returns nothing call AttachInteger( H2I( whichUnit ), "WeaponType", H2I( whichWeaponType ) ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function InitializeUnit takes unit whichUnit returns nothing call SaveInteger( "InitializeUnit", "whichUnitId", H2I( whichUnit ) ) call ExecuteFunc( "InitializeUnit_Child" ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function IssueImmediateOrderByIdWJ takes unit whichUnit, integer whichOrderId returns boolean local integer TriggerId = GetSavedInteger( "MainTriggers", "Unit_gets_an_Order" ) call DisableTrigger( I2Trigger( TriggerId ) ) if ( whichOrderId == Stop_OrderId() ) then if ( IsUnitPaused( whichUnit ) == false ) then //call PauseUnit( whichUnit, true ) call IssueImmediateOrderById( whichUnit, whichOrderId ) //call PauseUnit( whichUnit, false ) call EnableTrigger( I2Trigger( TriggerId ) ) return true endif call IssueImmediateOrderById( whichUnit, whichOrderId ) endif call IssueImmediateOrderById( whichUnit, whichOrderId ) call EnableTrigger( I2Trigger( TriggerId ) ) return false endfunction function IssuePointOrderByIdWJ takes unit whichUnit, integer whichOrderId, real x, real y returns boolean local integer TriggerId = GetSavedInteger( "MainTriggers", "Unit_gets_an_Order" ) call DisableTrigger( I2Trigger( TriggerId ) ) call IssuePointOrderById( whichUnit, whichOrderId, x, y ) call EnableTrigger( I2Trigger( TriggerId ) ) return false endfunction function IssueTargetOrderByIdWJ takes unit whichUnit, integer whichOrderId, widget whichTarget returns boolean local integer TriggerId = GetSavedInteger( "MainTriggers", "Unit_gets_an_Order" ) call DisableTrigger( I2Trigger( TriggerId ) ) call IssueTargetOrderById( whichUnit, whichOrderId, whichTarget ) call EnableTrigger( I2Trigger( TriggerId ) ) return false endfunction function UnitClearRequestQueue takes unit whichUnit returns nothing local integer iteration = 1 local integer whichUnitId = H2I( whichUnit ) local integer TriggerId = GetSavedInteger( "MainTriggers", "Unit_gets_an_Order" ) loop exitwhen ( iteration > 8 ) call AttachBoolean( TriggerId, "IgnoreNext", true ) call IssueImmediateOrderByIdWJ( whichUnit, Cancel_OrderId() ) set iteration = iteration + 1 endloop endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function SetUnitOwnerWJ takes unit whichUnit, player whichPlayer, boolean changeColor returns nothing local integer whichPlayerId = H2I( whichPlayer ) local integer whichUnitId = H2I( whichUnit ) call SetUnitOwner( I2Unit( whichUnitId ), I2Player( whichPlayerId ), changeColor ) endfunction function SetUnitOwnerEx takes unit whichUnit, player whichPlayer, boolean changeColor returns nothing local integer whichPlayerId = H2I( whichPlayer ) local integer whichUnitId = H2I( whichUnit ) local integer whichUnitOwnerId = H2I( GetOwningPlayer( I2Unit( whichUnitId ) ) ) local integer whichUnitFoodUsed = GetAttachedInteger( GetUnitTypeId( whichUnit ), "FoodUsed" ) call SetPlayerState( I2Player( whichUnitOwnerId ), PLAYER_STATE_RESOURCE_FOOD_USED, GetPlayerState( I2Player( whichUnitOwnerId ), PLAYER_STATE_RESOURCE_FOOD_USED ) - whichUnitFoodUsed ) call SetPlayerState( I2Player( whichPlayerId ), PLAYER_STATE_RESOURCE_FOOD_USED, GetPlayerState( I2Player( whichPlayerId ), PLAYER_STATE_RESOURCE_FOOD_USED ) + whichUnitFoodUsed ) call SetUnitOwnerWJ( I2Unit( whichUnitId ), I2Player( whichPlayerId ), changeColor ) endfunction function GetUnitZ takes unit whichUnit returns real local real whichUnitZ = GetFloorHeight( GetUnitX( whichUnit ), GetUnitY( whichUnit ) ) + GetUnitFlyHeight( whichUnit ) return whichUnitZ endfunction function SetUnitXEx takes unit whichUnit, real x returns nothing local real maxX = GetRectMaxX( udg_PlayRect ) local real minX = GetRectMinX( udg_PlayRect ) if ( x < minX ) then set x = minX elseif ( x > maxX ) then set x = maxX endif call SetUnitX( whichUnit, x ) endfunction function SetUnitYEx takes unit whichUnit, real y returns nothing local real maxY = GetRectMaxY( udg_PlayRect ) local real minY = GetRectMinY( udg_PlayRect ) if ( y < minY ) then set y = minY elseif ( y > maxY ) then set y = maxY endif call SetUnitY( whichUnit, y ) endfunction function SetUnitZEx takes unit whichUnit, real z returns nothing call UnitAddAbility( whichUnit, 'Amrf' ) call SetUnitFlyHeight( whichUnit, z - GetFloorHeight( GetUnitX( whichUnit ), GetUnitY( whichUnit ) ), 0 ) call UnitRemoveAbility( whichUnit, 'Amrf' ) endfunction function CheckMoveEvents_StonesThrow takes integer whichUnitId, real x, real y, real z returns nothing local integer UpdateTimerId = GetAttachedInteger( whichUnitId, "StonesThrow_UpdateTimerId" ) if ( ( I2Timer( UpdateTimerId ) != null ) and ( z <= GetFloorHeight( x, y ) ) ) then set udg_TempInteger[0] = UpdateTimerId call ExecuteFunc( "StonesThrow_Caster_Ending_Executed" ) endif endfunction function CheckMoveEvents takes integer whichUnitId, real x, real y, real z returns nothing call CheckMoveEvents_StonesThrow( whichUnitId, x, y, z ) endfunction function AddLightningFromPointToUnit_Child takes nothing returns nothing local integer UpdateTimerId = H2I( GetExpiredTimer() ) local integer LightningId = GetAttachedInteger( UpdateTimerId, "LightningId" ) local integer SourceId local real sourceX local real sourceY local real sourceZ local real sourceZOffset = GetAttachedReal( UpdateTimerId, "SourceZOffset" ) local integer TargetId local real targetX local real targetY local real targetZ local real targetZOffset = GetAttachedReal( UpdateTimerId, "TargetZOffset" ) local integer Type = GetAttachedInteger( UpdateTimerId, "Type" ) if ( Type == 1 ) then set SourceId = GetAttachedInteger( UpdateTimerId, "SourceId" ) set sourceX = GetUnitX( I2Unit( SourceId ) ) set sourceY = GetUnitY( I2Unit( SourceId ) ) set sourceZ = GetUnitZ( I2Unit( SourceId ) ) set TargetId = GetAttachedInteger( UpdateTimerId, "TargetId" ) set targetX = GetUnitX( I2Unit( TargetId ) ) set targetY = GetUnitY( I2Unit( TargetId ) ) set targetZ = GetUnitZ( I2Unit( TargetId ) ) elseif ( Type == 2 ) then set sourceX = GetAttachedReal( UpdateTimerId, "SourceX" ) set sourceY = GetAttachedReal( UpdateTimerId, "SourceY" ) set sourceZ = GetAttachedReal( UpdateTimerId, "SourceZ" ) set TargetId = GetAttachedInteger( UpdateTimerId, "TargetId" ) set targetX = GetUnitX( I2Unit( TargetId ) ) set targetY = GetUnitY( I2Unit( TargetId ) ) set targetZ = GetUnitZ( I2Unit( TargetId ) ) elseif ( Type == 3 ) then set SourceId = GetAttachedInteger( UpdateTimerId, "SourceId" ) set sourceX = GetUnitX( I2Unit( SourceId ) ) set sourceY = GetUnitY( I2Unit( SourceId ) ) set sourceZ = GetUnitZ( I2Unit( SourceId ) ) set targetX = GetAttachedReal( UpdateTimerId, "TargetX" ) set targetY = GetAttachedReal( UpdateTimerId, "TargetY" ) set targetZ = GetAttachedReal( UpdateTimerId, "TargetZ" ) endif call MoveLightningEx( I2Lightning( LightningId ), true, sourceX, sourceY, sourceZ + sourceZOffset, targetX, targetY, targetZ + targetZOffset ) endfunction function AddLightningBetweenUnits takes string codeName, unit source, real sourceZOffset, unit target, real targetZOffset returns lightning local integer newLightningId = H2I( AddLightningExWJ( codeName, GetUnitX( source ), GetUnitY( source ), GetUnitZ( source ) + sourceZOffset, GetUnitX( target ), GetUnitY( target ), GetUnitZ( target ) + targetZOffset ) ) local integer SourceId = H2I( source ) local integer TargetId = H2I( target ) local integer UpdateTimerId = H2I( CreateTimerWJ() ) call AttachInteger( newLightningId, "UpdateTimerId", UpdateTimerId ) call AddIntegerToTable( SourceId, "Lightning_UpdateTimers", UpdateTimerId ) call AddIntegerToTable( TargetId, "Lightning_UpdateTimers", UpdateTimerId ) call AttachInteger( UpdateTimerId, "LightningId", newLightningId ) call AttachInteger( UpdateTimerId, "SourceId", SourceId ) call AttachReal( UpdateTimerId, "SourceZOffset", sourceZOffset ) call AttachInteger( UpdateTimerId, "TargetId", TargetId ) call AttachReal( UpdateTimerId, "TargetZOffset", targetZOffset ) call AttachInteger( UpdateTimerId, "Type", 1 ) call TimerStart( I2Timer( UpdateTimerId ), 0.01, true, function AddLightningFromPointToUnit_Child ) return I2Lightning( newLightningId ) endfunction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function CreateUnitWJ takes player p, integer whichType, real x, real y, real face returns unit local real maxX = GetRectMaxX( udg_PlayRect ) local real maxY = GetRectMaxY( udg_PlayRect ) local real minX = GetRectMinX( udg_PlayRect ) local real minY = GetRectMinY( udg_PlayRect ) if ( x < minX ) then set x = minX elseif ( x > maxX ) then set x = maxX endif if ( y < minY ) then set y = minY elseif ( y > maxY ) then set y = maxY endif return CreateUnit( p, whichType, x, y, face ) endfunction function CreateUnitEx2 takes player whichPlayer, integer whichType, real x, real y, boolean useCollision, real face returns unit local integer newUnitId = H2I( CreateUnitWJ( whichPlayer, whichType, x, y, face ) ) call AddObject() if ( useCollision ) then call SetUnitPosition( I2Unit( newUnitId ), x, y ) else call SetUnitXEx( I2Unit( newUnitId ), x ) call SetUnitYEx( I2Unit( newUnitId ), y ) endif return I2Unit( newUnitId ) endfunction function CreateUnitEx takes player whichPlayer, integer whichType, real x, real y, boolean useCollision, real face returns unit local integer newUnitId = H2I( CreateUnitWJ( whichPlayer, whichType, x, y, face ) ) call AddObject() if ( useCollision ) then call SetUnitPosition( I2Unit( newUnitId ), x, y ) else call SetUnitXEx( I2Unit( newUnitId ), x ) call SetUnitYEx( I2Unit( newUnitId ), y ) endif call InitializeUnit( I2Unit( newUnitId ) ) return I2Unit( newUnitId ) endfunction function RemoveUnitWJ takes unit u returns nothing call RemoveUnit( u ) endfunction function RemoveUnitEx2 takes unit u returns nothing call RemoveObject( u ) call RemoveUnitWJ( u ) endfunction function RemoveRemainingReferenceFromUnit takes unit whichUnit returns nothing local integer whichUnitId = H2I( whichUnit ) local integer RemainingReferences = GetAttachedInteger( whichUnitId, "RemainingReferences" ) call AttachInteger( whichUnitId, "RemainingReferences", RemainingReferences ) if ( ( RemainingReferences == 0 ) and ( GetAttachedBoolean( whichUnitId, "WaitsForRemoval" ) ) ) then call FlushAttachedBoolean( whichUnitId, "WaitsForRemoval" ) call ShowUnit( whichUnit, true ) call RemoveUnitWJ( whichUnit ) endif endfunction function AddRemainingReferenceToUnit takes unit whichUnit returns nothing local integer whichUnitId = H2I( whichUnit ) call AttachInteger( whichUnitId, "RemainingReferences", GetAttachedInteger( whichUnitId, "RemainingReferences" ) ) endfunction function RemoveUnitEx takes unit DecayingUnit returns nothing call SaveInteger( "RemoveUnitEx", "DecayingUnitId", H2I( DecayingUnit ) ) call ExecuteFunc( "RemoveUnitEx_Child" ) endfunction function RemoveUnitExByTimer takes nothing returns nothing local integer DecayingTimerId = H2I( GetExpiredTimer() ) local integer DecayingUnitId = GetAttachedInteger( DecayingTimerId, "DecayingUnitId" ) call RemoveUnitEx( I2Unit( DecayingUnitId ) ) endfunction function RemoveUnitTimed_Removing takes nothing returns nothing local integer RemovingTimerId = H2I( GetExpiredTimer() ) local integer whichUnitId = GetAttachedInteger( RemovingTimerId, "whichUnitId" ) call RemoveUnitWJ( I2Unit( whichUnitId ) ) call FlushAttachedInteger( RemovingTimerId, "whichUnitId" ) call DestroyTimerWJ( I2Timer( RemovingTimerId ) ) endfunction function RemoveUnitTimed takes unit whichUnit, real time returns nothing local integer whichUnitId = H2I( whichUnit ) local integer RemovingTimerId = H2I( CreateTimerWJ() ) call AttachInteger( RemovingTimerId, "whichUnitId", whichUnitId ) call TimerStart( I2Timer( RemovingTimerId ), time, false, function RemoveUnitTimed_Removing ) endfunction function InitTrig_Unit takes nothing returns nothing endfunction