function GetUnitItemSlot (unit, item)
slot = 0
if UnitHasItem(unit, item) then
size = UnitInventorySize(unit)
while slot < size do
if UnitItemInSlot(unit, slot) == item then
return slot
end
slot = slot + 1
end
end
return -1
end
function IsAIPlayer (p)
return p == Player(0) or p == Player(1) or p == Player(2) or p == Player(3) or p == Player(4) or p == Player(5)
end
function IsSpellBook (item)
type = GetItemTypeId(item)
return type == FourCC("grsl") or type == FourCC("dtsb") or type == FourCC("tmsc") or type == FourCC("I00H") or type == FourCC("I00C") or type == FourCC("I00D") or type == FourCC("I00G") or type == FourCC("I00A") or type == FourCC("I00B") or type == FourCC("I00F") or type == FourCC("I00E") or type == FourCC("sfog")
end
function HasPillage (unit)
return GetUnitAbilityLevel(unit, FourCC("A01Q")) > 0
end
function HasGiantsbane (unit)
return UnitHasItem(unit, FourCC("iwbr")) or UnitHasItem(unit, FourCC("klmm"))
end
function HasBow (unit, tier)
if tier == 1 then
return GetUnitAbilityLevel(source, FourCC("A01S")) > 0
elseif tier == 2 then
return GetUnitAbilityLevel(source, FourCC("A039")) > 0
else
return GetUnitAbilityLevel(source, FourCC("A01S")) > 0 or GetUnitAbilityLevel(source, FourCC("A039")) > 0
end
end
function IsMelee (unit)
return IsUnitType(unit, UNIT_TYPE_MELEE_ATTACKER)
end
function IsFavored (unit)
local p = GetOwningPlayer(unit)
local loc = GetUnitLoc(unit)
local allies = GetUnitsInRangeOfLocMatching(500.0, loc, function ()
return not IsUnitEnemy(GetEnumUnit(), p)
end)
local enemies = GetUnitsInRangeOfLocMatching(500.0, loc, function ()
return IsUnitEnemy(GetEnumUnit(), p)
end)
local b = not CountUnitsInGroup(enemies) > CountUnitsInGroup(allies)
RemoveLocation(loc)
DestroyGroup(allies)
DestroyGroup(enemies)
return b
end
function FixSpellBookSwaps (unit, order, swapper)
if order >= 852002 and order <= 852007 then
from = GetUnitItemSlot(unit, swapper)
to = order - 852002
target = UnitItemInSlot(unit, to)
if from ~= to then
if target == null then
if IsSpellBook(swapper) then
id = GetItemTypeId(swapper)
RemoveItem(swapper)
UnitAddItemToSlotById(unit, id, to)
end
else
targetid = GetItemTypeId(target)
swapperid = GetItemTypeId(swapper)
targetcharges = GetItemCharges(target)
swappercharges = GetItemCharges(swapper)
RemoveItem(target)
RemoveItem(swapper)
UnitAddItemToSlotById(unit, targetid, from)
UnitAddItemToSlotById(unit, swapperid, to)
SetItemCharges(UnitItemInSlot(unit, from), targetcharges)
SetItemCharges(UnitItemInSlot(unit, to), swappercharges)
end
end
end
end
Name | Type | is_array | initial_value |
AIPlayer | player | Yes | |
AllianceVotes | boolean | Yes | |
ArticBlizzard | effect | No | |
BanditArmyCaptains | unit | Yes | |
BanditRaidCaptains | unit | Yes | |
Blockers | group | No | |
CaravanDestinations | rect | Yes | |
CaravanMerchants | unit | Yes | |
Caravans | unit | Yes | |
Chaos | unit | No | |
CitadelShield | effect | No | |
Cursors | location | Yes | |
DragonHeroPlayer | player | No | |
DragonLords | unit | Yes | |
DragonQuesting | boolean | Yes | |
Hero | unit | Yes | |
HeroPlayer | player | Yes | |
Location | location | No | |
Mode | string | No | pvp |
PhysicsUnits | group | No | |
PlayerColor | string | Yes | |
Portal | effect | No | |
PrisonerCages | unit | Yes | |
PrisonerEscapees | unit | Yes | |
PrisonerPlayer | player | No | |
PrivateerCargo | item | Yes | |
PrivateerDestinations | rect | Yes | |
PrivateerShoremen | unit | Yes | |
Quake | effect | No | |
SecondHero | unit | Yes | |
UnitPhysics | hashtable | No |
function Spells ()
udg_SpellTimers = InitHashtable()
end
function DummyCleanup ()
t = GetExpiredTimer()
caster = LoadUnitHandle(udg_SpellTimers, GetHandleId(t), StringHash("caster"))
FlushChildHashtable(udg_SpellTimers, GetHandleId(t))
FlushChildHashtable(udg_SpellTimers, GetHandleId(caster))
RemoveUnit( caster )
PauseTimer( t )
DestroyTimer( t )
t = null
end
function DummySource (caster)
return LoadUnitHandle(udg_SpellTimers, GetHandleId(caster), StringHash("source"))
end
function DummyCaster (source, abil, time)
t = CreateTimer()
p = GetOwningPlayer(source)
caster = CreateUnit( p, FourCC("h001"), GetUnitX(source), GetUnitY(source), GetUnitFacing(source) )
UnitAddAbility( caster, abil )
SetUnitUserData( caster, abil )
TimerStart(t, time, false, DummyCleanup)
SaveUnitHandle(udg_SpellTimers, GetHandleId(caster), StringHash("source"), source)
SaveUnitHandle(udg_SpellTimers, GetHandleId(t), StringHash("caster"), caster)
return caster
end
function UnitItemDamage (u)
local item
local d
local damage = 0
local slot = 0
local size = UnitInventorySize(u)
while slot < size do
item = UnitItemInSlot(unit, slot)
if item ~= null then
-- only added damage, str/agi/int handled elsewhere..
d = ({
[FourCC("rat3")] = 3, --Dagger
[FourCC("I008")] = 3, --Hand Axe
[FourCC("rat6")] = 6, --Claws
[FourCC("mlst")] = 7, --Maul of Strength
[FourCC("rat9")] = 9, --Broad Sword
[FourCC("stwa")] = 10, --Battle Axe
[FourCC("ratc")] = 12, --Long Sword
[FourCC("ratf")] = 15, --Flamberge
[FourCC("ocor")] = 6, --Orb of Corruption
[FourCC("ofr2")] = 6, --Orb of Fire
[FourCC("oli2")] = 6, --Orb of Lightning
[FourCC("oven")] = 6, --Orb of Venom
[FourCC("odef")] = 6, --Orb of Darkness
[FourCC("ofro")] = 6, --Orb of Frost
[FourCC("asbl")] = 5, --Assassins Blade
[FourCC("frgd")] = 6, --Frostguard
[FourCC("srtl")] = 15, --Serathil
[FourCC("srbd")] = 10, --Storm Hammer
[FourCC("phlt")] = 10, --Valkyrie Spear
})[GetItemTypeId(item)]
if d ~= null then
damage = damage + d
end
end
slot = slot + 1
end
return damage
end
function HeroStatDamage (u)
local str = GetHeroStr(u, false)
local agi = GetHeroAgi(u, false)
local int = GetHeroInt(u, false)
if str >= agi and str >= int then
return IMaxBJ( 0, GetHeroStr(u, true) - str )
elseif agi >= str and agi >= int then
return IMaxBJ( 0, GetHeroAgi(u, true) - agi )
else
return IMaxBJ( 0, GetHeroInt(u, true) - int )
end
end
function UnitProcDamage (u)
return BlzGetUnitBaseDamage(u, 0) + GetRandomInt(1, BlzGetUnitDiceSides(u, 0)) * BlzGetUnitDiceNumber(u, 0) + UnitItemDamage(u) + HeroStatDamage(u)
end
function Frost (source, target)
local caster = CreateUnit( GetOwningPlayer(source), FourCC("h001"), GetUnitX(target), GetUnitY(target), GetUnitFacing(source) )
UnitAddAbility( caster, FourCC("A018") )
IssueTargetOrder( caster , "frostnova", target )
TimerStart(CreateTimer(), 1.0, true, function ( )
RemoveUnit( caster )
DestroyTimer( GetExpiredTimer() )
end)
end
function HasAbility (u, abil)
return GetUnitAbilityLevel(u, abil) > 0
end
function IsAlive (u)
return IsUnitAliveBJ(u)
end
function IsStructure (u)
return IsUnitType(u, UNIT_TYPE_STRUCTURE)
end
function IsUndead (u)
return IsUnitType(u, UNIT_TYPE_UNDEAD)
end
function IsAquatic (u)
return HasAbility(u, FourCC("Asa2"))
end
function IsGiant (u)
return ({
[FourCC("hkni")] = true,
[FourCC("otau")] = true,
[FourCC("uabo")] = true,
[FourCC("emtg")] = true,
[FourCC("nwna")] = true,
[FourCC("nmgd")] = true,
[FourCC("nsgg")] = true,
[FourCC("nggr")] = true,
[FourCC("nogl")] = true,
[FourCC("nogm")] = true,
[FourCC("nomg")] = true,
[FourCC("nogr")] = true,
[FourCC("nehy")] = true,
[FourCC("nahy")] = true,
[FourCC("ntrd")] = true,
[FourCC("ntrg")] = true,
[FourCC("ntrt")] = true,
[FourCC("nplg")] = true,
[FourCC("nsgt")] = true,
[FourCC("nsbm")] = true,
[FourCC("nwlg")] = true,
[FourCC("nwwg")] = true,
[FourCC("nskg")] = true,
[FourCC("nowk")] = true,
[FourCC("n007")] = true,
[FourCC("nnwq")] = true,
[FourCC("nnws")] = true,
[FourCC("nsgn")] = true,
[FourCC("nsgb")] = true,
[FourCC("nsgh")] = true,
})[GetUnitTypeId(u)] ~= null
end
function IsAirborne (u)
return IsUnitInGroup(u, udg_PhysicsUnits) or IsUnitType(u, UNIT_TYPE_FLYING)
end
function IsInfernal (u)
return HasAbility(u, FourCC("AIfw")) or HasAbility(u, FourCC("ANpi")) or HasAbility(u, FourCC("Apig"))
end
function IsFrost (u)
return HasAbility(u, FourCC("AIft")) or HasAbility(u, FourCC("Afra")) or HasAbility(u, FourCC("ACfa"))
end
function Damage (u, target, damage, at, dt)
local loc = GetUnitLoc(u)
local order = OrderId2StringBJ(GetUnitCurrentOrder(target))
if damage == 0 or GetUnitTypeId(target) == FourCC("h001") then
RemoveLocation(loc)
return
end
if dt == DAMAGE_TYPE_ENHANCED then
if IsStructure(target) then
damage = damage * 0.5
end
end
if dt == DAMAGE_TYPE_DIVINE and IsUndead(target) then
damage = damage * 1.5
end
if dt == DAMAGE_TYPE_FIRE then
if IsFrost(target) then
damage = damage * 1.5
end
if IsInfernal(target) then
damage = damage * 0.5
end
end
if dt == DAMAGE_TYPE_COLD then
if IsStructure(target) then
damage = damage * 0.5
end
if IsInfernal(target) then
damage = damage * 1.5
end
if IsFrost(target) then
damage = damage * 0.5
end
end
if dt == DAMAGE_TYPE_LIGHTNING then
if IsStructure(target) then
damage = damage * 0.35
elseif IsAquatic(target) or IsAirborne(target) then
damage = damage * 1.5
end
end
if GetOwningPlayer(target) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and (order == "" or order == "move") then
IssuePointOrderLoc( target, "attack", loc)
end
UnitDamageTargetBJ( u, target, damage, at, dt )
RemoveLocation(loc)
end
function Physics ()
udg_UnitPhysics = InitHashtable()
end
function SetUnitVelocity ( u, vx, vy, vz )
if (HaveSavedReal(udg_UnitPhysics, GetHandleId(u), StringHash("vz")) == false) then
GroupAddUnit(udg_PhysicsUnits, u)
UnitAddAbility(u, FourCC("Amrf"))
UnitRemoveAbility(u, FourCC("Amrf"))
SetUnitPropWindow(u, 0)
end
SaveReal(udg_UnitPhysics, GetHandleId(u), StringHash("vx"), vx)
SaveReal(udg_UnitPhysics, GetHandleId(u), StringHash("vy"), vy)
SaveReal(udg_UnitPhysics, GetHandleId(u), StringHash("vz"), vz)
end
function AddUnitVelocity ( u, dvx, dvy, dvz )
vx = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vx"))
vy = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vy"))
vz = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vz"))
SetUnitVelocity(u, vx+dvx, vy+dvy, vz+dvz)
end
function DistanceBetweenUnits ( a, b )
aL = GetUnitLoc(a)
bL = GetUnitLoc(b)
distance = DistanceBetweenPoints(aL, bL)
RemoveLocation(aL)
RemoveLocation(bL)
aL = null
bL = null
return distance
end
function DistanceBetweenUnitTarget ( a, t )
aL = GetUnitLoc(a)
distance = DistanceBetweenPoints(aL, t)
RemoveLocation(aL)
aL = null
return distance
end
function AngleBetweenUnits ( a, b )
aL = GetUnitLoc(a)
bL = GetUnitLoc(b)
angle = AngleBetweenPoints(aL, bL)
RemoveLocation(aL)
RemoveLocation(bL)
aL = null
bL = null
return angle
end
function AngleBetweenUnitTarget ( a, t )
aL = GetUnitLoc(a)
angle = AngleBetweenPoints(aL, t)
RemoveLocation(aL)
aL = null
return angle
end
function IsUnitInSightOfUnit ( observer, target, fov )
face = GetUnitFacing(observer)
angle = bj_RADTODEG*Atan2(GetUnitY(target) - GetUnitY(observer), GetUnitX(target) - GetUnitX(observer))
return not (RAbsBJ(face - angle) > fov and RAbsBJ(face - angle - 360.) > fov)
end
function ClosestUnit ( u, p, type )
local distance = 42000.0
local e
local closest
local d
ForGroupBJ( GetUnitsOfPlayerAndTypeId(p, type), function ( )
e = GetEnumUnit()
if closest ~= null then
d = DistanceBetweenUnits(e, closest)
if d < distance then
closest = e
distance = d
end
else
closest = e
end
end )
return closest
end
function PhysicsUpdate ( u )
x = GetUnitX(u)
y = GetUnitY(u)
z = GetUnitFlyHeight(u)
vx = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vx"))
vy = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vy"))
vz = LoadReal(udg_UnitPhysics, GetHandleId(u), StringHash("vz"))
az = -1000.0
dt = 0.05
vz = vz+az*dt
x = x+vx*dt
y = y+vy*dt
z = z+vz*dt
if (z < 0) then
z = 0
callback = LoadTriggerHandle(udg_UnitPhysics, GetHandleId(u), StringHash("callback"))
FlushChildHashtable(udg_UnitPhysics, GetHandleId(u))
GroupRemoveUnit(udg_PhysicsUnits, u)
SetUnitPropWindow(u, GetUnitDefaultPropWindow(u))
IssueImmediateOrderBJ(u, "stop")
else
SetUnitVelocity(u, vx, vy, vz)
end
SetUnitX(u, x)
SetUnitY(u, y)
SetUnitFlyHeight(u, z, 0)
if (callback ~= null) then
ConditionalTriggerExecute( callback )
end
end
function ProcTextTag (loc, s, size, r, g, b)
CreateTextTagLocBJ( s, OffsetLocation(loc, -15, 0), 0, size, r, g, b, 0 )
SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
SetTextTagFadepointBJ( GetLastCreatedTextTag(), 2 )
SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3 )
SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
end
function DamageEffect (source, target)
local abil = GetUnitUserData(source)
local lvl = 0
local dt = BlzGetEventDamageType()
local at = BlzGetEventAttackType()
local tt = GetUnitTypeId(target)
local damage = GetEventDamage()
local loc = GetUnitLoc(target)
local fx
local x
local y
local g
local f = ({
[FourCC("A00G")] = PowershotUnit,
})[abil]
if f ~= null then
f()
end
if at == ATTACK_TYPE_NORMAL and GetUnitAbilityLevel(source, FourCC("A01U")) > 0 then
Damage(source, target, (damage * 0.25), ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL)
end
if at == ATTACK_TYPE_HERO and GetUnitAbilityLevel(source, FourCC("A02M")) > 0 then
Damage(source, target, (damage * 0.25), ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL)
end
if R2I(damage) > 2 then
if at == ATTACK_TYPE_NORMAL and dt == DAMAGE_TYPE_ENHANCED then
ProcTextTag(loc, I2S(R2I(damage)).."!", 11, 100, 0, 0)
SetTextTagVisibility(GetLastCreatedTextTag(), GetLocalPlayer() == GetOwningPlayer(source) or GetLocalPlayer() == GetOwningPlayer(target))
elseif at == ATTACK_TYPE_NORMAL or dt == DAMAGE_TYPE_ENHANCED then
ProcTextTag(loc, I2S(R2I(damage)), 8, 80, 0, 0)
SetTextTagVisibility(GetLastCreatedTextTag(), GetLocalPlayer() == GetOwningPlayer(source) or GetLocalPlayer() == GetOwningPlayer(target))
end
end
if (at ~= ATTACK_TYPE_NORMAL and dt == DAMAGE_TYPE_NORMAL and BlzGetUnitRealField( source, UNIT_RF_MANA_REGENERATION ) < 0.00 ) then
SetUnitManaBJ( source, ( GetUnitStateSwap(UNIT_STATE_MANA, source) + 3.00 ) )
end
if (dt == DAMAGE_TYPE_NORMAL and IsUnitInGroup(target, udg_Blockers)) then
BlzSetEventDamage( damage * 0.25 )
fx = AddSpecialEffectTarget( "Abilities\\Spells\\Items\\SpellShieldAmulet\\SpellShieldCaster.mdl", target, "origin" )
DestroyEffect( fx )
GroupRemoveUnit( udg_Blockers, target )
IssueImmediateOrder( target, "undefend" )
end
if at == ATTACK_TYPE_HERO and HasPillage(source) and IsStructure(target) and IsUnitEnemy(target, GetOwningPlayer(source)) then
if GetRandomInt(0,1) == 0 then
g = GetRandomInt(1,5)
else
g = GetRandomInt(2,3)
end
AdjustPlayerStateBJ(g, GetOwningPlayer(source), PLAYER_STATE_RESOURCE_GOLD)
ProcTextTag(PolarProjectionBJ(loc, 25, 90), "+"..g, 7, 100, 85, 0)
SetTextTagVisibility(GetLastCreatedTextTag(), GetLocalPlayer() == GetOwningPlayer(source))
end
if at == ATTACK_TYPE_HERO and HasGiantsbane(source) and IsGiant(target) and IsUnitEnemy(target, GetOwningPlayer(source)) then
Damage(source, target, (damage * 0.25), ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL)
end
if at == ATTACK_TYPE_HERO and HasBow(source, 0) and DistanceBetweenUnits(source, target) > 200.0 then
if HasBow(source, 2) then
Damage(source, target, (damage * 0.35), ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL)
elseif HasBow(source, 1) then
Damage(source, target, (damage * 0.25), ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL)
end
if not IsStructure(target) then
fx = AddSpecialEffectTarget( "Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodLarge0.mdl", target, "origin" )
DestroyEffect( fx )
end
end
-- AI Reactions
if dt == DAMAGE_TYPE_NORMAL and IsAIPlayer(GetOwningPlayer(target)) and IsUnitEnemy(source, GetOwningPlayer(target)) then
RemoveLocation(loc)
if (IsMelee(source) and not IsMelee(target)) or GetUnitLifePercent(target) < 35.0 then
loc = GetPlayerStartLocationLoc(GetOwningPlayer(target))
if DistanceBetweenPoints(GetUnitLoc(target), loc) > 1000.0 then
-- Run Away
IssuePointOrderLocBJ( target, "move", loc )
end
end
end
RemoveLocation(loc)
end
function AbilitySpell ( )
local f = ({
[FourCC("A00Z")] = Slash,
[FourCC("A010")] = Thunderstrike,
[FourCC("A00H")] = Powershot,
[FourCC("A00I")] = Arcshot,
[FourCC("A014")] = Uppercut,
[FourCC("A015")] = DownwardStrike,
[FourCC("A016")] = Disintegrate,
[FourCC("A017")] = FrostRay,
})[GetSpellAbilityId()]
if f ~= null then
f()
end
end
function Slash ( )
local hero = GetTriggerUnit()
local loc = GetUnitLoc(hero)
local fx = AddSpecialEffectTarget( "war3mapImported\\Slash.mdx", hero, "origin" )
ForGroup(GetUnitsInRangeOfLocAll(250, loc), function ( )
local u = GetEnumUnit()
local damage = 1.25 * UnitProcDamage( hero )
if (IsAlive(u) and IsUnitEnemy(u, GetOwningPlayer(hero)) and IsUnitInSightOfUnit(hero, u, 150.0)) then
Damage( hero, u, damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
end
end)
TriggerSleepAction( 2.00 )
DestroyEffect(fx)
RemoveLocation(loc)
end
function Thunderstrike ( )
local damage = 1.5 * UnitProcDamage(GetTriggerUnit())
Damage( GetTriggerUnit(), GetSpellTargetUnit(), damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_LIGHTNING )
end
function PowershotUnit ( )
local u = BlzGetEventDamageTarget()
local hero = DummySource(GetEventDamageSource())
local damage = 1.50 * UnitProcDamage(hero)
if (IsAlive(u) and IsUnitEnemy(u, GetOwningPlayer(hero))) then
Damage( hero, u, damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
end
end
function Powershot ( )
IssuePointOrderLoc( DummyCaster( GetTriggerUnit(), FourCC("A00G"), 3.0 ), "carrionswarm", GetSpellTargetLoc() )
end
function Arcshot ( )
local source = GetTriggerUnit()
local loc = GetSpellTargetLoc()
local launcher = CreateUnit( GetOwningPlayer(source), FourCC("h002"), GetUnitX(source), GetUnitY(source), GetUnitFacing(source) )
local fx
IssuePointOrderLocBJ( launcher, "attackground", loc )
TriggerSleepAction( DistanceBetweenUnitTarget(source, loc) / 900.0 )
ForGroup(GetUnitsInRangeOfLocAll(125, loc), function ( )
local u = GetEnumUnit()
local damage = R2I(2.0 * UnitProcDamage(source))
if (IsAlive(u) and IsUnitEnemy(u, GetOwningPlayer(source))) then
Damage( source, u, damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
end
end)
fx = AddSpecialEffect( "Abilities\\Weapons\\BallistaMissile\\BallistaMissileTarget.mdl", GetLocationX(loc), GetLocationY(loc) )
TriggerSleepAction( 1.00 )
DestroyEffect( fx )
RemoveUnit( launcher )
RemoveLocation( loc )
end
function Uppercut ( )
local hero = GetTriggerUnit()
local loc = GetUnitLoc(hero)
local fx = AddSpecialEffectTarget( "war3mapImported\\SlashUp.mdx", hero, "origin" )
ForGroup(GetUnitsInRangeOfLocAll(200, loc), function ( )
local u = GetEnumUnit()
local loc = GetUnitLoc(u)
local damage = R2I(1.25 * UnitProcDamage(hero))
local fx
local angle = AngleBetweenUnits(hero, u)
local distance = 25
if (IsAlive(u) and not IsStructure(u) and IsUnitEnemy(u, GetOwningPlayer(hero)) and IsUnitInSightOfUnit(hero, u, 35.0)) then
Damage( hero, u, damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
SetUnitVelocity( u, distance*CosBJ(angle), distance*SinBJ(angle), 650 )
fx = AddSpecialEffectTarget( "Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl", hero, "origin" )
BlzSetSpecialEffectColor( fx, 255, 185, 185 )
DestroyEffect(fx)
end
RemoveLocation(loc)
end)
TriggerSleepAction( 2.00 )
DestroyEffect(fx)
RemoveLocation(loc)
end
function DownwardStrike ( )
local hero = GetTriggerUnit()
local loc = GetUnitLoc(hero)
local fx = AddSpecialEffectTarget( "war3mapImported\\SlashDown.mdx", hero, "origin" )
BlzSetSpecialEffectTimeScale( fx, 0.75 )
ForGroup(GetUnitsInRangeOfLocAll(250, loc), function ( )
local u = GetEnumUnit()
local loc = GetUnitLoc(u)
local damage = UnitProcDamage(hero)
local fx
local angle = AngleBetweenUnits(hero, u)
local distance = 250
if (IsAlive(u) and IsUnitEnemy(u, GetOwningPlayer(hero)) and IsUnitInSightOfUnit(hero, u, 35.0)) then
if not IsStructure(u) and IsAirborne(u) then
damage = R2I(2.0 * damage)
Damage( hero, u, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
SetUnitVelocity( u, distance*CosBJ(angle), distance*SinBJ(angle), -300 )
fx = AddSpecialEffectTarget( "Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl", u, "origin" )
DestroyEffect( fx )
else
damage = R2I(1.5 * damage)
Damage( hero, u, damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
end
end
RemoveLocation( loc )
end)
TriggerSleepAction( 2.00 )
DestroyEffect( fx )
RemoveLocation( loc )
end
function Disintegrate ( )
local source = GetTriggerUnit()
local facing = AngleBetweenUnitTarget( source, GetSpellTargetLoc() )
local loc = GetUnitLoc(source)
local beam = PolarProjectionBJ(PolarProjectionBJ(GetUnitLoc(source), 620, facing), 0, facing + 135)
local fx = AddSpecialEffectLoc( "war3mapImported\\Disintegrate.mdx", beam )
local ang = Atan((GetLocationZ(loc) - GetLocationZ(beam)) / DistanceBetweenPoints(beam, loc))
BlzSetSpecialEffectTimeScale( fx, 2.0 )
BlzSetSpecialEffectScale( fx, 0.45 )
BlzSetSpecialEffectZ( fx, GetLocationZ(beam) + 75 )
BlzSetSpecialEffectYaw( fx, Deg2Rad(facing - 8) )
BlzSetSpecialEffectPitch( fx, Deg2Rad(-98) + ang )
local t = CreateTimer()
local tfx = CreateTimer()
TimerStart(t, 0.35, true, function ( )
local t = GetExpiredTimer()
local cursor = udg_Cursors[GetConvertedPlayerId(GetOwningPlayer(source))]
local facing = AngleBetweenUnitTarget( source, cursor )
local mana = GetUnitState(source, UNIT_STATE_MANA)
local g
if (mana < 1) then
IssueImmediateOrder( source, "stop" )
end
if (GetUnitCurrentOrder(source) ~= String2OrderIdBJ("fingerofdeath")) then
PauseTimer(t)
DestroyTimer(t)
else
g = GetUnitsInRangeOfLocAll(75, PolarProjectionBJ(GetUnitLoc(source), 75, facing))
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 100, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 250, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 400, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 550, facing)), g)
ForGroup(g, function ( )
local target = GetEnumUnit()
local loc = GetUnitLoc(target)
local damage = 0.75 * UnitProcDamage(source)
local fx
local water = not IsTerrainPathableBJ(loc, PATHING_TYPE_FLOATABILITY)
local snow = GetTerrainTypeBJ(loc) == FourCC("cWc1")
if water or snow then
damage = R2I(0.75 * damage)
end
if (IsAlive(target) and IsUnitEnemy(target, GetOwningPlayer(source))) then
Damage( source, target, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
fx = AddSpecialEffect( "Abilities\\Spells\\Undead\\CarrionSwarm\\CarrionSwarmDamage.mdl", GetUnitX(target), GetUnitY(target) )
BlzSetSpecialEffectHeight( fx, 50.0 )
BlzSetSpecialEffectScale( fx, 0.80 )
TriggerSleepAction(1.00)
DestroyEffect(fx)
end
RemoveLocation(loc)
end)
SetUnitState(source, UNIT_STATE_MANA, mana - 8)
end
DestroyGroup(g)
end)
TimerStart(tfx, 0.05, true, function ( )
local t = GetExpiredTimer()
local cursor = udg_Cursors[GetConvertedPlayerId(GetOwningPlayer(source))]
local facing = AngleBetweenUnitTarget( source, cursor )
local loc = GetUnitLoc(source)
local beam = PolarProjectionBJ(PolarProjectionBJ(loc, 650, facing), 0, facing + 135)
local mana = GetUnitState(source, UNIT_STATE_MANA)
local ang
local fx
local fm
if (GetUnitCurrentOrder(source) ~= String2OrderIdBJ("fingerofdeath") or mana < 1) then
PauseTimer(t)
DestroyTimer(t)
else
SetUnitFacing(source, facing)
fx = AddSpecialEffectLoc( "war3mapImported\\Disintegrate.mdx", beam )
ang = Atan((GetLocationZ(loc) - GetLocationZ(beam)) / 650.0)
BlzSetSpecialEffectTimeScale( fx, 2.0 )
BlzSetSpecialEffectScale( fx, 0.4 + GetRandomReal(0, 0.1) )
BlzSetSpecialEffectZ( fx, GetLocationZ(beam) + 75 )
BlzSetSpecialEffectYaw( fx, Deg2Rad(facing - 8) )
BlzSetSpecialEffectPitch( fx, Deg2Rad(-98) + ang )
fm = CreateFogModifierRadius(GetOwningPlayer(source), FOG_OF_WAR_VISIBLE, GetLocationX(beam), GetLocationY(beam), 150.0, true, true)
TimerStart(CreateTimer(), 1.0, true, function ( )
DestroyFogModifier( fm )
DestroyTimer( GetExpiredTimer() )
end)
end
RemoveLocation(beam)
RemoveLocation(loc)
DestroyEffect(fx)
end)
RemoveLocation(beam)
DestroyEffect(fx)
RemoveLocation(loc)
end
function FrostRay ( )
local source = GetTriggerUnit()
local facing = AngleBetweenUnitTarget( source, GetSpellTargetLoc() )
local loc = GetUnitLoc(source)
local beam = PolarProjectionBJ(PolarProjectionBJ(GetUnitLoc(source), 635, facing), 0, facing + 135)
local fx = AddSpecialEffectLoc( "war3mapImported\\FrostRay.mdx", beam )
local ang = Atan((GetLocationZ(loc) - GetLocationZ(beam)) / DistanceBetweenPoints(beam, loc))
BlzSetSpecialEffectTimeScale( fx, 2.0 )
BlzSetSpecialEffectScale( fx, 0.45 )
BlzSetSpecialEffectZ( fx, GetLocationZ(beam) + 75 )
BlzSetSpecialEffectYaw( fx, Deg2Rad(facing - 8) )
BlzSetSpecialEffectPitch( fx, Deg2Rad(-98) + ang )
local t = CreateTimer()
local tfx = CreateTimer()
TimerStart(t, 0.35, true, function ( )
local t = GetExpiredTimer()
local cursor = udg_Cursors[GetConvertedPlayerId(GetOwningPlayer(source))]
local facing = AngleBetweenUnitTarget( source, cursor )
local mana = GetUnitState(source, UNIT_STATE_MANA)
local g
if (mana < 1) then
IssueImmediateOrder( source, "stop" )
end
if (GetUnitCurrentOrder(source) ~= String2OrderIdBJ("manaburn")) then
PauseTimer(t)
DestroyTimer(t)
else
g = GetUnitsInRangeOfLocAll(75, PolarProjectionBJ(GetUnitLoc(source), 75, facing))
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 100, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 250, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 400, facing)), g)
GroupAddGroup(GetUnitsInRangeOfLocAll(100, PolarProjectionBJ(GetUnitLoc(source), 550, facing)), g)
ForGroup(g, function ( )
local target = GetEnumUnit()
local loc = GetUnitLoc(target)
local damage = 0.75 * UnitProcDamage(source)
local fx
if (IsAlive(target) and IsUnitEnemy(target, GetOwningPlayer(source))) then
Damage( source, target, damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_COLD )
fx = AddSpecialEffect( "Abilities\\Spells\\Items\\AIob\\AIobSpecialArt.mdl", GetUnitX(target), GetUnitY(target) )
BlzSetSpecialEffectHeight( fx, 100.0 )
BlzSetSpecialEffectScale( fx, 0.80 )
Frost( source, target )
TriggerSleepAction(1.00)
DestroyEffect(fx)
end
RemoveLocation(loc)
end)
SetUnitState(source, UNIT_STATE_MANA, mana - 10)
end
DestroyGroup(g)
end)
TimerStart(tfx, 0.05, true, function ( )
local t = GetExpiredTimer()
local cursor = udg_Cursors[GetConvertedPlayerId(GetOwningPlayer(source))]
local facing = AngleBetweenUnitTarget( source, cursor )
local loc = GetUnitLoc(source)
local beam = PolarProjectionBJ(PolarProjectionBJ(loc, 650, facing), 0, facing + 135)
local mana = GetUnitState(source, UNIT_STATE_MANA)
local ang
local fx
local fm
if (GetUnitCurrentOrder(source) ~= String2OrderIdBJ("manaburn") or mana < 1) then
PauseTimer(t)
DestroyTimer(t)
else
SetUnitFacing(source, facing)
fx = AddSpecialEffectLoc( "war3mapImported\\FrostRay.mdx", beam )
ang = Atan((GetLocationZ(loc) - GetLocationZ(beam)) / DistanceBetweenPoints(beam, loc))
BlzSetSpecialEffectTimeScale( fx, 2.0 )
BlzSetSpecialEffectScale( fx, 0.4 + GetRandomReal(0, 0.1) )
BlzSetSpecialEffectZ( fx, GetLocationZ(beam) + 75 )
BlzSetSpecialEffectYaw( fx, Deg2Rad(facing - 8) )
BlzSetSpecialEffectPitch( fx, Deg2Rad(-98) + ang )
fm = CreateFogModifierRadius(GetOwningPlayer(source), FOG_OF_WAR_VISIBLE, GetLocationX(beam), GetLocationY(beam), 150.0, true, true)
TimerStart(CreateTimer(), 1.0, true, function ( )
DestroyFogModifier( fm )
DestroyTimer( GetExpiredTimer() )
end)
end
RemoveLocation(beam)
RemoveLocation(loc)
DestroyEffect(fx)
end)
RemoveLocation(beam)
DestroyEffect(fx)
RemoveLocation(loc)
end
function HumanAI ()
HumanWorkers()
HumanBuild()
end
function HumanBuild ()
local g = GetUnitsOfPlayerMatching(GetEnumPlayer(), Condition(function ()
return IsUnitType(GetFilterUnit(), UNIT_TYPE_PEON)
end))
if GetPlayerUnitTypeCount(GetEnumPlayer(), FourCC("hbar")) < 1 then
IssueBuildOrderByIdLocBJ( FirstOfGroup(g), FourCC("hbar"), GetPlayerStartLocationLoc(GetEnumPlayer()) )
end
end
function HumanWorkers ()
local g = GetUnitsOfPlayerMatching(GetEnumPlayer(), Condition(function ()
return IsUnitType(GetFilterUnit(), UNIT_TYPE_PEON)
end))
local idlers = 0
local miners = 0
local lumberjacks = 0
-- inventory
ForGroup(g, function ( )
local worker = GetEnumUnit()
local order = OrderId2StringBJ(GetUnitCurrentOrder(worker))
if order == "stop" or order == "" then
idlers = idlers + 1
elseif order == "harvest" or order == "resumeharvesting" then
miners = miners + 1
end
end)
-- commands
ForGroup(g, function ( )
local worker = GetEnumUnit()
local order = OrderId2StringBJ(GetUnitCurrentOrder(worker))
if order == "stop" or order == "" then
if miners < 6 then
IssueImmediateOrderBJ( worker, "autoharvestgold" )
else
IssueImmediateOrderBJ( worker, "autoharvestlumber" )
end
end
end)
DestroyGroup(g)
end
function HumanFighters ()
end
function OrcAI ()
HumanWorkers()
end
function OrcBuild ()
end
function OrcWorkers ()
end
function OrcFighters ()
end
function UndeadAI ()
HumanWorkers()
end
function UndeadBuild ()
end
function UndeadWorkers ()
end
function UndeadFighters ()
end
function ElfAI ()
HumanWorkers()
end
function ElfBuild ()
end
function ElfWorkers ()
end
function ElfFighters ()
end