//TESH.scrollpos=520
//TESH.alwaysfold=0
// ===========================
function DistanceBetweenPointsXY takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))
endfunction
function AngleBetweenPointsXY takes real x1, real y1, real x2, real y2 returns real
return Atan2BJ((y2-y1),(x2-x1))
endfunction
function StartSoundUnit takes string id, unit c returns nothing
local sound snd=CreateSound(id,false,true,false,10,10,"")
call SetSoundPitch(snd,GetRandomReal(0.8,1.2))
call SetSoundVolume(snd,GetRandomInt(90,120))
call AttachSoundToUnit(snd,c)
call StartSound(snd)
call KillSoundWhenDone(snd)
set snd=null
endfunction
function InputMsgI takes player id, string prompttext, string options returns integer
local dialog prompt = DialogCreate()
local trigger array trig
local string current=""
local integer n=0
local integer i=0
local integer result=0
call DialogSetMessage( prompt, prompttext )
set trig[0] = CreateTrigger()
call TriggerRegisterDialogEvent( trig[0], prompt )
set options=options+";"
loop
exitwhen SubString(options,i,i+1) == ""
if SubString(options,i,i+1) == ";" then
set n=n+1
set trig[n] = CreateTrigger()
call TriggerRegisterDialogButtonEvent( trig[n], DialogAddButton( prompt, current,0 ) )
set current=""
else
set current=current+SubString(options,i,i+1)
endif
set i=i+1
endloop
if n==0 then
return 0
endif
call DialogDisplay( id, prompt, true)
loop
exitwhen GetTriggerEvalCount(trig[0]) > 0
call TriggerSleepAction(0)
endloop
set i=0
call DialogClear(prompt)
call DialogDestroy(prompt)
set prompt=null
loop
exitwhen i>n
if GetTriggerEvalCount(trig[i]) > 0 then
set result = i
endif
call DestroyTrigger(trig[i])
set trig[i] = null
set i=i+1
endloop
return result
endfunction
function MoveUnitToPolarProjection takes unit tomove, real dist, real angle returns nothing
call SetUnitPosition(tomove, GetUnitX(tomove) + dist * Cos(angle * bj_DEGTORAD) , GetUnitY(tomove) + dist * Sin(angle * bj_DEGTORAD))
endfunction
function CreateDummy takes player pl, location loc, real duration returns unit
local unit m = CreateUnitAtLoc(pl,'u000',loc,0)
call UnitApplyTimedLife(m,'BTLF',duration)
return m
endfunction
function CreateDummyEx takes player pl, location loc, real fly, real size, real duration returns unit
local unit m = CreateUnitAtLoc(pl,'u000',loc,GetRandomDirectionDeg())
call SetUnitFlyHeight(m,fly,999999)
call SetUnitScale(m,size,size,size)
call UnitApplyTimedLife(m,'BTLF',duration)
return m
endfunction
function AddTimedEffectExpire takes nothing returns nothing
local timer t = GetExpiredTimer()
local effect fx = GetHandleEffect(t, "fx")
call DestroyEffect(fx)
call DestroyTimer(t)
set fx = null
set t = null
endfunction
function AddTimedEffectTarget takes unit target, string path, string bone, real duration returns nothing
local timer expire = CreateTimer()
local effect fx = AddSpecialEffectTarget(path, target, bone)
call SetHandleHandle(expire, "fx", fx)
call TimerStart(expire, duration, false, function AddTimedEffectExpire)
set expire = null
set fx = null
endfunction
function AddTimedEffect takes real x, real y, string path, real duration returns nothing
local timer expire = CreateTimer()
local effect fx = AddSpecialEffect(path, x, y)
call SetHandleHandle(expire, "fx", fx)
call TimerStart(expire, duration, false, function AddTimedEffectExpire)
set expire = null
set fx = null
endfunction
function AddSpecialEffectTargetUnitAuto_Child takes nothing returns nothing
local effect tempeffect = GetHandleEffect(GetTriggeringTrigger(), "effect")
call DestroyEffect( tempeffect )
call DestroyTrigger(GetTriggeringTrigger())
endfunction
function AddSpecialEffectTargetUnitAuto takes string whichAttach, unit whichUnit, string whichEffect returns nothing
local trigger dispatcher = CreateTrigger()
local effect tempeffect = AddSpecialEffectTargetUnitBJ(whichAttach, whichUnit, whichEffect)
call SetHandleHandle(dispatcher, "effect", tempeffect)
call TriggerAddAction( dispatcher, function AddSpecialEffectTargetUnitAuto_Child )
call TriggerRegisterUnitEvent(dispatcher, whichUnit, EVENT_UNIT_DEATH)
endfunction
function SimulateStun_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local effect e=GetHandleEffect(t, "Effect")
local unit u=GetHandleUnit(t, "Unit")
call DestroyEffect(e)
call PauseUnit(u,false)
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t=null
set e=null
set u=null
endfunction
function SimulateStun takes unit whichUnit, real dur returns nothing
local timer t=CreateTimer()
call SetHandleHandle(t, "Effect", AddSpecialEffectTargetUnitBJ("overhead", whichUnit, "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl"))
call SetHandleHandle(t, "Unit", whichUnit)
call PauseUnit(whichUnit, true)
call TimerStart(t, dur, false, function SimulateStun_Child)
set whichUnit=null
set t=null
endfunction
//===========================================================================
//
// Action system
//
//===========================================================================
function Stuck takes unit c returns nothing
call SetUnitPosition(c,GetUnitX(c),GetUnitY(c))
endfunction
function Gibs_Pool takes nothing returns nothing
local timer t=GetExpiredTimer()
local real x=GetHandleReal(t,"x")
local real y=GetHandleReal(t,"y")
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t=null
call AddTimedEffect(x,y,"blood.mdl",3)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Orc\\OrcSmallDeathExplode\\OrcSmallDeathExplode.mdl",x,y))
set t=null
endfunction
function Gibs_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local timer t2=CreateTimer()
local integer abilID=GetHandleInt(t,"abilID")
local real random=GetHandleReal(t,"random")
local real size=GetHandleReal(t,"size")
local real Fmin=GetHandleReal(t,"Fmin")
local real Fmax=GetHandleReal(t,"Fmax")
local unit m
local real x=GetHandleReal(t,"x")
local real y=GetHandleReal(t,"y")
local real x2=x+CosBJ(GetRandomDirectionDeg())*GetRandomReal(1,random)
local real y2=y+SinBJ(GetRandomDirectionDeg())*GetRandomReal(1,random)
local real w=(DistanceBetweenPointsXY(x,y,x2,y2)/700)*1.5
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t=null
set m=CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),'u000',x,y,0)
call SetUnitFlyHeight(m,GetRandomReal(Fmin,Fmax),999999)
call SetUnitScale(m,size,size,size)
call UnitAddAbility(m,abilID)
call IssuePointOrder(m,"clusterrockets",x2,y2)
call UnitApplyTimedLife(m,'BTLF',3)
call StartSoundUnit("gibsplt1.mp3",m)
set m=null
call SetHandleReal(t2,"x",x2)
call SetHandleReal(t2,"y",y2)
call TimerStart(t2,w,false,function Gibs_Pool)
set t2=null
endfunction
function Gibs takes real x, real y, integer abilID, real random, real size, real Fmin, real Fmax, real Wmin, real Wmax returns nothing
local timer t=CreateTimer()
local real time=GetRandomReal(Wmin,Wmax)
call SetHandleReal(t,"x",x)
call SetHandleReal(t,"y",y)
call SetHandleInt(t,"abilID",abilID)
call SetHandleReal(t,"random",random)
call SetHandleReal(t,"size",size)
call SetHandleReal(t,"Fmin",Fmin)
call SetHandleReal(t,"Fmax",Fmax)
call TimerStart(t,time,false,function Gibs_Child)
set t=null
endfunction
function GibsBurst takes real x, real y, integer id, integer gibmin, integer gibmax, real random, real min, real max, real fmin, real fmax, real wmin, real wmax returns nothing
local integer gibs=GetRandomInt(gibmin,gibmax)
local integer gib=0
loop
exitwhen gib>=gibs
call Gibs(x,y,id,random,GetRandomReal(min,max),fmin,fmax,wmin,wmax)
set gib=gib+1
endloop
endfunction
function Push_units_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t,"u")
local integer duration=GetHandleInt(t,"duration")
local real angle=GetHandleReal(t,"a")
if duration<=0 then
call FlushHandleLocals(t)
call PauseTimer(t)
call DestroyTimer(t)
else
call MoveUnitToPolarProjection(u,GetHandleReal(t,"pushback"),angle)
call SetHandleInt(t,"duration",duration-1)
call DestroyEffect(AddSpecialEffectTarget(GetHandleString(t,"fx"),u,"origin"))
endif
set u=null
set t=null
endfunction
function Push_units takes unit u1, unit u2, real push, integer duration, real time, string fx returns nothing
local timer t=CreateTimer()
call SetHandleHandle(t,"u",u2)
call SetHandleReal(t,"pushback",push)
call SetHandleInt(t,"duration",duration)
call SetHandleString(t,"fx",fx)
call SetHandleReal(t,"a",AngleBetweenPointsXY(GetUnitX(u1),GetUnitY(u1),GetUnitX(u2),GetUnitY(u2)))
call TimerStart(t,time,true,function Push_units_Child)
set t=null
endfunction
function Push_angle_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t,"u")
local integer duration=GetHandleInt(t,"duration")
local real angle=GetHandleReal(t,"angle")
if (GetHandleInt(t,"turn")==1) then
call SetHandleReal(t,"angle",angle + GetHandleReal(t,"ang"))
call SetUnitFacing(u,GetHandleReal(t,"angle"))
endif
if duration<=0 then
call FlushHandleLocals(t)
call DestroyTimer(t)
call ResetUnitAnimation(u)
call Stuck(u)
else
call MoveUnitToPolarProjection(u,GetHandleReal(t,"pushback"),angle)
call SetHandleInt(t,"duration",duration-1)
call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",u,GetHandleString(t,"fx")))
endif
set u = null
set t = null
endfunction
function Push_angle takes real u1, unit u2, real push, integer dur, real time, string fx, real ang, integer turn returns nothing
local timer t=CreateTimer()
call SetHandleHandle(t,"u",u2)
call SetHandleReal(t,"angle",u1)
call SetHandleReal(t,"pushback",push)
call SetHandleInt(t,"duration",dur)
call SetHandleReal(t,"ang",ang)
call SetHandleInt(t,"turn",turn)
call SetHandleString(t,"fx",fx)
call TimerStart(t,time, true, function Push_angle_Child)
call SetUnitAnimation(u2,"stand ready")
set t=null
set u2=null
endfunction
function LeapAttackFilterEnemy takes nothing returns boolean
return GetBooleanAnd( GetBooleanAnd(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false, GetFilterUnit() != GetHandleUnit(GetExpiredTimer(), "whichUnit") ), GetBooleanAnd( IsUnitAliveBJ(GetFilterUnit()) == true, GetBooleanAnd( IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true, IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetHandleUnit(GetExpiredTimer(), "whichUnit"))) == true) ) )
endfunction
function LeapAttackFilterAll takes nothing returns boolean
return GetBooleanAnd( GetBooleanAnd(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false, GetFilterUnit() != GetHandleUnit(GetExpiredTimer(), "whichUnit") ), GetBooleanAnd( IsUnitAliveBJ(GetFilterUnit()) == true, IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true ) )
endfunction
function LeapAttack_Damage takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t, "whichUnit")
call UnitDamageTargetBJ(u, GetEnumUnit(), GetHandleReal(t, "damage"), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
call SimulateStun(GetEnumUnit(), GetHandleReal(t, "stunDur"))
set t=null
set u=null
endfunction
function LeapAttack_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t, "whichUnit")
local location current=GetUnitLoc(u)
local group g
local location new=PolarProjectionBJ(current, 30, GetHandleReal(t, "angle"))
local real r=GetHandleReal(t,"r")+30
call SetUnitPositionLoc( u, new )
if (GetHandleBoolean(t, "heighset") == false) then
if ( r >= ( GetHandleReal(t, "distance") / 2.00 ) ) then
call SetUnitFlyHeight( u, 0.00, 2500.00 )
call SetHandleBoolean(t, "heighset", true)
endif
endif
call SetHandleReal(t,"r",r)
if ( r >= GetHandleReal(t, "distance") ) then
if (GetHandleBoolean(t, "hitAllies") == true) then
set g = GetUnitsInRangeOfLocMatching(GetHandleReal(t, "area"), new, Condition(function LeapAttackFilterAll))
else
set g = GetUnitsInRangeOfLocMatching(GetHandleReal(t, "area"), new, Condition(function LeapAttackFilterEnemy))
endif
call ForGroup(g, function LeapAttack_Damage)
call FlushHandleLocals(t)
call DestroyTimer(t)
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", new))
call SetUnitInvulnerable(u,false)
call SetUnitPathing(u,true)
call SetUnitTimeScalePercent(u,100.00)
call PauseUnit(u,false)
call ResetUnitAnimation(u)
call SetUnitPositionLoc(u,current)
call StartSoundUnit("fall1.mp3",u)
endif
call DestroyGroup(g)
set g=null
call RemoveLocation(current)
set current=null
call RemoveLocation(new)
set new=null
set u=null
set t=null
endfunction
function LeapAttack takes unit whichUnit, location targetLoc, real damage, real stunDur, real area, boolean hitAllies returns nothing
local timer t=CreateTimer()
local location l=Location(GetUnitX(whichUnit)+1,GetUnitY(whichUnit)+1)
call UnitAddAbility(whichUnit, 'Amrf')
call UnitRemoveAbility(whichUnit, 'Amrf')
call SetUnitInvulnerable( whichUnit, true )
call SetUnitAnimation( whichUnit, "attack slam" )
call SetUnitPathing( whichUnit, false )
if DistanceBetweenPoints(l,targetLoc)>30 then
call SetUnitFlyHeight( whichUnit, 10000.00, 2500.00 ) // This is to prevent the unit from flying away if the target point is at the point of the unit itself.
endif
call SetUnitTimeScalePercent( whichUnit, 5.00 )
call PauseUnit(whichUnit, true)
call SetHandleHandle(t, "whichUnit", whichUnit)
call SetHandleReal(t, "damage", damage)
call SetHandleReal(t, "stunDur", stunDur)
call SetHandleReal(t, "area", area)
call SetHandleReal(t, "endX", GetLocationX(targetLoc))
call SetHandleReal(t, "endY", GetLocationY(targetLoc))
call SetHandleReal(t, "distance", DistanceBetweenPoints(l, targetLoc))
call SetHandleReal(t, "angle", AngleBetweenPoints(l, targetLoc))
call SetHandleBoolean(t, "hitAllies", hitAllies)
call TimerStart(t, 0.03, true, function LeapAttack_Child)
call RemoveLocation(l)
set l=null
set whichUnit=null
set t=null
endfunction
function UnitKO takes unit u, unit c, real dur returns nothing
call SetUnitUserData(u,0)
call SetUnitAnimation(u,"death")
call SetUnitFacing(u,GetUnitFacing(u)+180)
call SimulateStun(u,dur)
call SetUnitAnimation(u,"death")
call Push_units(c,u,30,6,0.03,"Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl")
endfunction
function GroupKO takes unit c, real rad, real dur returns nothing
local unit u
local group g
local location loc=GetUnitLoc(c)
set g = GetUnitsInRangeOfLocAll(rad,loc)
call RemoveLocation(loc)
set loc=null
call GroupRemoveUnit(g,c)
loop
set u=FirstOfGroup(g)
exitwhen u==null
if IsUnitType(u,UNIT_TYPE_HERO) then
call UnitKO(u,c,dur)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g=null
set u=null
set c=null
endfunction
function Headless takes unit u returns nothing
call GibsBurst(GetUnitX(u),GetUnitY(u),'A003',4,9,400,0.7,1,75,150,0.5,2)
call AddTimedEffectTarget(u,"blood.mdl","head",10)
call AddTimedEffectTarget(u,"blood.mdl","head",10)
call AddTimedEffectTarget(u,"blood.mdl","head",10)
call DestroyEffect(AddSpecialEffectTargetUnitBJ("head",u,"Objects\\Spawnmodels\\Orc\\OrcSmallDeathExplode\\OrcSmallDeathExplode.mdl"))
call UnitApplyTimedLife(u,'BTLF',6)
call UnitAddAbility(u,'A004')
endfunction
function Armless takes unit u returns nothing
call GibsBurst(GetUnitX(u),GetUnitY(u),'A003',1,5,300,0.7,1,30,100,0.5,2)
call AddSpecialEffectTargetUnitAuto("left,hand",u,"blood.mdl")
call AddSpecialEffectTargetUnitAuto("right,hand",u,"blood.mdl")
call UnitAddAbility(u,'A005')
endfunction
function Legless takes unit u returns nothing
call GibsBurst(GetUnitX(u),GetUnitY(u),'A003',1,5,300,0.7,1,20,100,0.5,2)
call AddSpecialEffectTargetUnitAuto("foot",u,"blood.mdl")
call AddSpecialEffectTargetUnitAuto("foot",u,"blood.mdl")
call UnitAddAbility(u,'A007')
endfunction
function Invul_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t,"u")
local effect fx=GetHandleEffect(t,"fx")
call SetUnitInvulnerable(u,false)
call UnitRemoveAbility(u,'A00G')
call DestroyEffect(fx)
call FlushHandleLocals(t)
call PauseTimer(t)
call DestroyTimer(t)
set t=null
set fx=null
set u=null
endfunction
function Invul takes unit u returns nothing
local timer t=CreateTimer()
local effect fx=AddSpecialEffectTarget("Abilities\\Spells\\Orc\\Voodoo\\VoodooAuraTarget.mdl",u,"overhead")
call UnitAddAbility(u,'A00G')
call SetUnitInvulnerable(u,true)
call SetHandleHandle(t,"u",u)
call SetHandleHandle(t,"fx",fx)
call TimerStart(t,7,false,function Invul_Child)
set t=null
set fx=null
endfunction
function UpgradeFix takes unit c returns integer
local integer x
if IsUnitType(c,UNIT_TYPE_HERO) and GetPlayerState(GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)>=15 then
set x=InputMsgI(GetOwningPlayer(c),"What do you want to upgrade?","Sakkat;Blade;CANCEL")
if x==1then
return 0
elseif x==2then
return 1
endif
endif
return 3
endfunction
function Upgrade takes unit u, integer i returns nothing
local string fx
local integer z=-15
if i==0 then
// SAKKAT
set fx = "Abilities\\Spells\\Other\\AcidBomb\\BottleMissile.mdl"
if GetUnitAbilityLevel(u,'A006')==1 then
// does nothing
set fx = ""
set z=0
call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(u)),5,"Your Sakkat is already upgraded on maximum.")
call Upgrade(u,UpgradeFix(u))
elseif GetUnitAbilityLevel(u,'A008')==1 then
call UnitAddAbility(u,'A006') // high sakkat
call IncUnitAbilityLevel(u,'A00D')
call UnitRemoveAbility(u,'A008')
elseif GetUnitAbilityLevel(u,'A009')==1 then
call UnitAddAbility(u,'A008') // medium sakkat
call UnitRemoveAbility(u,'A009')
call IncUnitAbilityLevel(u,'A00D')
else
call UnitAddAbility(u,'A009') // low sakkat
call UnitAddAbility(u,'A00D')
endif
elseif i==1 then
// BLADE
set fx = "Abilities\\Spells\\Other\\HealingSpray\\HealBottleMissile.mdl"
if GetUnitAbilityLevel(u,'A00A')==1 then
// does nothing
set fx = ""
set z=0
call DisplayTimedTextToForce(GetForceOfPlayer(GetOwningPlayer(u)),5,"Your Blade is already upgraded on maximum.")
call Upgrade(u,UpgradeFix(u))
elseif GetUnitAbilityLevel(u,'A00B')==1 then
call UnitAddAbility(u,'A00A') // high blade
call IncUnitAbilityLevel(u,'A00E')
call UnitRemoveAbility(u,'A00B')
elseif GetUnitAbilityLevel(u,'A00C')==1 then
call UnitAddAbility(u,'A00B') // medium blade
call UnitRemoveAbility(u,'A00C')
call IncUnitAbilityLevel(u,'A00E')
else
call UnitAddAbility(u,'A00C') // low blade
call UnitAddAbility(u,'A00E')
endif
endif
call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",u,fx))
call AdjustPlayerStateBJ(z,GetOwningPlayer(u),PLAYER_STATE_RESOURCE_LUMBER)
endfunction
function PreloadAll takes nothing returns nothing
local unit u=CreateUnit(Player(15),'ndog',-500,-2685,270)
call Preload("blood.mdl")
call Preload("dummy.mdl")
call Preload("PandaHatLow.mdl")
call Preload("PandaHatMedium.mdl")
call Preload("PandaHatHigh.mdl")
call UnitAddAbility(u,'A003')
call UnitRemoveAbility(u,'A003')
// bonuses
call UnitAddAbility(u,'A00D')
call UnitRemoveAbility(u,'A00D')
call UnitAddAbility(u,'A00E')
call UnitRemoveAbility(u,'A00E')
// upgrades
call UnitAddAbility(u,'A00C')
call UnitRemoveAbility(u,'A00C')
call UnitAddAbility(u,'A00B')
call UnitRemoveAbility(u,'A00B')
call UnitAddAbility(u,'A00A')
call UnitRemoveAbility(u,'A00A')
call UnitAddAbility(u,'A009')
call UnitRemoveAbility(u,'A009')
call UnitAddAbility(u,'A008')
call UnitRemoveAbility(u,'A008')
call UnitAddAbility(u,'A006')
call UnitRemoveAbility(u,'A006')
// torning abilities
call UnitAddAbility(u,'A007')
call UnitRemoveAbility(u,'A007')
call UnitAddAbility(u,'A005')
call UnitRemoveAbility(u,'A005')
call UnitAddAbility(u,'A004')
call UnitRemoveAbility(u,'A004')
set u=null
endfunction
Name | Type | is_array | initial_value |
attacked | unit | No | |
attacker | unit | No | |
MB | multiboard | No | |
MB_DEATHS | integer | Yes | |
MB_KILLS | integer | Yes |
//TESH.scrollpos=3
//TESH.alwaysfold=0
//==========================================================================================
library HandleVars initializer init
globals
private hashtable ht
endglobals
// too bad the Handle vars' old functionality forces me to make these things
// inline-unfriendly
function SetHandleHandle takes agent subject, string label, agent value returns nothing
if(value==null) then
call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
else
call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
endif
endfunction
function SetHandleInt takes agent subject, string label, integer value returns nothing
if value==0 then
call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
else
call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
endif
endfunction
function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
if (value == false) then
call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
else
call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
endif
endfunction
function SetHandleReal takes agent subject, string label, real value returns nothing
if (value == 0.0) then
call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
else
call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
endif
endfunction
function SetHandleString takes agent subject, string label, string value returns nothing
if ((value=="") or (value==null)) then
call RemoveSavedString(ht, GetHandleId(subject), StringHash(label))
else
call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz' consistent naming scheme...
endif
endfunction
function GetHandleHandle takes agent subject, string label returns agent
debug call BJDebugMsg("[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake")
return null
endfunction
// these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
// GetHandleId as non-state changing. But they will be once I fix jasshelper...
function GetHandleInt takes agent subject, string label returns integer
return LoadInteger(ht, GetHandleId(subject), StringHash(label))
endfunction
function GetHandleBoolean takes agent subject, string label returns boolean
return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
endfunction
function GetHandleString takes agent subject, string label returns string
return LoadStr(ht, GetHandleId(subject), StringHash(label))
endfunction
function GetHandleReal takes agent subject, string label returns real
return LoadReal(ht, GetHandleId(subject), StringHash(label))
endfunction
// got bored so I now use a textmacro...
//! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
function SetHandle$NAME$ takes agent subject, string label, $TYPE$ value returns nothing
if(value==null) then
call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
else
call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
endif
endfunction
function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
endfunction
//! endtextmacro
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
//! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")
function FlushHandleVars takes agent subject returns nothing
call FlushChildHashtable(ht, GetHandleId(subject))
endfunction
function FlushHandleLocals takes agent subject returns nothing
call FlushHandleVars(subject)
endfunction
private function init takes nothing returns nothing
set ht=InitHashtable()
endfunction
endlibrary
//===========================================================================
function InitTrig_handlevars takes nothing returns nothing
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_ini_Actions takes nothing returns nothing
call PreloadAll()
call SetGameSpeed(MAP_SPEED_FASTEST)
call LockGameSpeedBJ()
call SetTimeOfDay(12)
call SetTimeOfDayScalePercentBJ(200)
call FogMaskEnableOff()
call TriggerExecute(gg_trg_start)
call TriggerSleepAction(1)
call TriggerExecute(gg_trg_MB)
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED,"Credits","|c00CECAA8Map creator|r : SnaKy|n|c00CECAA8Jass|r : KaTTaNa , Vexorian , Blade.DK , Youma|n|c00CECAA8Models|r : Black_Stan , Crazynutter|n|c00CECAA8Ideas|r : Cyberatog","ReplaceableTextures\\CommandButtons\\BTNSpiritLink.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED,"Commands","|c00CECAA8-suicide|r - makes suicide (if you stuck or something)","ReplaceableTextures\\CommandButtons\\BTNSilence.blp")
endfunction
//===========================================================================
function InitTrig_ini takes nothing returns nothing
set gg_trg_ini = CreateTrigger( )
call TriggerAddAction( gg_trg_ini, function Trig_ini_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
//===========================================================================
//
// Ai System
//
//===========================================================================
function GetEnemyi takes nothing returns boolean
return ( GetOwningPlayer(GetFilterUnit()) != Player(PLAYER_NEUTRAL_PASSIVE) )
endfunction
function GetEnemy takes nothing returns unit
return GroupPickRandomUnit(GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function GetEnemyi)))
endfunction
function GetEnemyiX takes nothing returns boolean
return IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO)
endfunction
function GetEnemyX takes integer p returns unit
return GroupPickRandomUnit(GetUnitsOfPlayerMatching(ConvertedPlayer(p), Condition(function GetEnemyiX)))
endfunction
function AI_well takes unit c returns nothing
local location loc = GetUnitLoc( GroupPickRandomUnit(GetUnitsOfTypeIdAll('nfoh')) )
if GetTerrainCliffLevelBJ(loc) != GetTerrainCliffLevel(GetUnitX(c),GetUnitY(c)) then
call IssuePointOrderLoc(c,"acidbomb",loc)
else
call IssuePointOrderLoc(c,"move",loc)
endif
call RemoveLocation(loc)
set loc = null
endfunction
function AI_well2 takes unit c returns nothing
local location loc = GetUnitLoc( GroupPickRandomUnit(GetUnitsOfTypeIdAll('nmoo')) )
if GetTerrainCliffLevelBJ(loc) != GetTerrainCliffLevel(GetUnitX(c),GetUnitY(c)) then
call IssuePointOrderLoc(c,"acidbomb",loc)
else
call IssuePointOrderLoc(c,"move",loc)
endif
call RemoveLocation(loc)
set loc = null
endfunction
function AI_task takes unit c returns nothing
local location loc = GetRandomLocInRect(GetPlayableMapRect())
local location loc2 = GetUnitLoc(c)
if GetTerrainCliffLevelBJ(loc) != GetTerrainCliffLevelBJ(loc2) then
if IssuePointOrderLoc(c,"acidbomb",loc)==false then
set loc = PolarProjectionBJ(loc2,GetRandomReal(300,1000),GetRandomDirectionDeg())
endif
call IssuePointOrderLoc(c,"acidbomb",loc)
else
call IssuePointOrderLoc(c,"attack",loc)
call TriggerSleepAction(0.5)
endif
if GetRandomInt(1,10)>5 then
call SelectHeroSkill(c,'A00F')
else
call SelectHeroSkill(c,'A002')
endif
call RemoveLocation(loc)
set loc = null
call RemoveLocation(loc2)
set loc2 = null
endfunction
function AI_dodge takes unit c returns nothing
call IssueImmediateOrder(c,"blink")
call TriggerSleepAction(1.5)
call AI_task(c)
endfunction
function AI_leapattack takes unit c, unit u returns nothing
local location loc = GetUnitLoc(u)
set u = null
call IssuePointOrderLoc(c,"acidbomb",loc)
call RemoveLocation(loc)
set loc = null
call TriggerSleepAction(0.5)
call AI_task(c)
endfunction
function AI_upgrade takes unit c returns nothing
local location loc = GetRandomLocInRect(gg_rct_Taoist)
call IssuePointOrderLoc(c,"acidbomb",loc)
call RemoveLocation(loc)
set loc = null
call TriggerSleepAction(0.5)
call AI_task(c)
endfunction
function AI_spells takes unit c, unit u returns nothing
if IssueImmediateOrder(c,"blizzard") then
call IssueImmediateOrder(c,"blizzard")
else
call IssueTargetOrder(c,"ambush",u)
endif
set u=null
endfunction
function AI_ini takes nothing returns nothing
local trigger t=GetTriggeringTrigger()
local real time
local integer random
local unit c=GetHandleUnit(t,"c")
local unit target=GetEnemy()
local integer array angry
local integer w
call FlushHandleLocals(t)
call DestroyTrigger(t)
set t=null
set angry[1]=3
set angry[2]=3
set angry[3]=3
set angry[4]=3
set angry[5]=3
set angry[6]=3
loop
exitwhen target!=c
set target=GetEnemy()
endloop
loop
exitwhen IsUnitDeadBJ(c)
// returns unit with highest angression following AI unit
if angry[1]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(1)
elseif angry[2]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(2)
elseif angry[3]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(3)
elseif angry[4]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(4)
elseif angry[5]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(5)
elseif angry[6]>angry[GetConvertedPlayerId(GetOwningPlayer(target))] then
set target = GetEnemyX(6)
endif
// hp
if GetUnitLifePercent(c) >= 50 then
call AI_task(c)
set time=2
else
set random=GetRandomInt(1,7)
if random==1 then
call AI_task(c)
set time=1.5
elseif random==2 then
call AI_dodge(c)
set time=2
elseif random==3 or random==4 then
call AI_well(c)
set time=5
elseif random==5 or random==6 then
call AI_well2(c)
set time=5
elseif random==7 then
call AI_well(c)
set time=11
endif
endif
// yet another column, but for mp
if GetUnitManaPercent(c) < 60 then
set random=GetRandomInt(1,3)
if random==1 then
call AI_task(c)
set time=1.5
else
call AI_well2(c)
set time=8
endif
endif
if GetRandomInt(0,10)>8 and GetPlayerState(GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)>=15 then
call AI_upgrade(c)
set time=0.2
endif
// attacking by myself, because i've got angry
if angry[GetConvertedPlayerId(GetOwningPlayer(target))+1]>GetRandomInt(1,angry[GetConvertedPlayerId(GetOwningPlayer(target))]*2) then
set random = GetRandomInt(1,6)
if random==1 or random==2 then
call AI_leapattack(c,target)
set time=1
elseif random==3 then
call AI_dodge(c)
set time=2
elseif random==4 then
call AI_spells(c,target)
set time=0.5
endif
endif
// attacked?
if c == udg_attacked then
set target=udg_attacker
set angry[GetConvertedPlayerId(GetOwningPlayer(target))+1] = angry[GetConvertedPlayerId(GetOwningPlayer(target))] + GetRandomInt(1,12*R2I(time+1))
set random=GetRandomInt(1,5)
if random==1 then
call AI_leapattack(c,target)
set time=1
elseif random==2 then
call AI_leapattack(c,target)
call AI_dodge(c)
set time=2
elseif random==3 then
call AI_spells(c,target)
set time=0.5
endif
endif
call TriggerSleepAction(time)
call Stuck(c)
endloop
set c=null
set target=null
endfunction
function AI_Start takes unit c returns nothing
local trigger t = CreateTrigger()
call SetHandleHandle(t,"c",c)
call TriggerAddAction(t,function AI_ini)
call TriggerExecute(t)
call DestroyTrigger(t)
set t = null
endfunction
//===========================================================================
function Trig_start_Actions takes nothing returns nothing
local unit z
local integer a = 1
local player p
loop
exitwhen a>6
set p = ConvertedPlayer(a)
set z = GroupPickRandomUnit(GetUnitsOfPlayerAll(p))
if ( GetPlayerSlotState(p) == PLAYER_SLOT_STATE_EMPTY ) and (GetPlayerController(p) != MAP_CONTROL_COMPUTER) then
call RemoveUnit(z)
endif
if ( GetPlayerController(p) == MAP_CONTROL_COMPUTER ) and z!=null then
call AI_Start(z)
endif
call Invul(z)
call SelectUnitForPlayerSingle(z,p)
set a = a + 1
endloop
set p = null
set z = null
endfunction
//===========================================================================
function InitTrig_start takes nothing returns nothing
set gg_trg_start = CreateTrigger( )
call TriggerAddAction( gg_trg_start, function Trig_start_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Refix takes unit u returns nothing
loop
exitwhen GetUnitAbilityLevel(u,'A005')==0
call UnitRemoveAbility(u,'A005')
endloop
loop
exitwhen GetUnitAbilityLevel(u,'A007')==0
call UnitRemoveAbility(u,'A007')
endloop
loop
exitwhen GetUnitAbilityLevel(u,'A004')==0
call UnitRemoveAbility(u,'A004')
endloop
call SetUnitUserData(u,0)
endfunction
function Trig_kill_Conditions takes nothing returns boolean
return IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO)
endfunction
function Trig_kill_Actions takes nothing returns nothing
local unit c=GetDyingUnit()
local unit k=GetKillingUnit()
local player p=GetOwningPlayer(c)
local location loc=GetUnitLoc(c)
local integer cp=GetConvertedPlayerId(p)
local integer kp=GetConvertedPlayerId(GetOwningPlayer(k))
local real wait
if c!=k and k!=null then
set udg_MB_KILLS[kp]=udg_MB_KILLS[kp]+1
endif
set udg_MB_DEATHS[cp]=udg_MB_DEATHS[cp]+1
call MultiboardSetItemValueBJ( udg_MB, 2, ( kp + 1 ), I2S(udg_MB_KILLS[kp]) )
call MultiboardSetItemValueBJ( udg_MB, 3, ( cp + 1 ), I2S(udg_MB_DEATHS[cp]) )
call AdjustPlayerStateBJ(3,GetOwningPlayer(GetKillingUnit()),PLAYER_STATE_RESOURCE_LUMBER)
call GibsBurst(GetUnitX(c),GetUnitY(c),'A003',2,9,500,0.7,1.5,20,100,0.2,1)
call Refix(c)
call StartSoundUnit("death1.mp3",c)
set wait=10+I2R(udg_MB_DEATHS[cp]*3)
if wait>30 then
set wait=30
endif
call QuestMessageBJ(GetPlayersAll(),bj_QUESTMESSAGE_HINT,GetPlayerName(p)+" will be revived in "+I2S(R2I(wait))+" seconds.")
call TriggerSleepAction(wait)
set loc=GetRandomLocInRect(GetPlayableMapRect())
call ReviveHeroLoc(c,loc,true)
set loc = GetUnitLoc(c)
call PanCameraToTimedLocForPlayer(p,loc,1)
call Invul(c)
call SelectUnitForPlayerSingle(c,p)
if GetPlayerController(p)==MAP_CONTROL_COMPUTER then
call AI_Start(c)
endif
call RemoveLocation(loc)
set loc=null
set p=null
set c=null
endfunction
//===========================================================================
function InitTrig_kill takes nothing returns nothing
set gg_trg_kill = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_kill, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_kill, Condition( function Trig_kill_Conditions ) )
call TriggerAddAction( gg_trg_kill, function Trig_kill_Actions )
endfunction
function Trig_leave_ai_Actions takes nothing returns nothing
local unit z = GroupPickRandomUnit(GetUnitsOfPlayerAll( GetTriggerPlayer() ))
call SetPlayerController(GetTriggerPlayer(),MAP_CONTROL_COMPUTER)
call AI_Start(z)
call DisplayTimedTextToForce(GetPlayersAll(),10,"|cff0000ff"+GetPlayerName(GetTriggerPlayer())+" has left the game.")
set z = null
endfunction
//===========================================================================
function InitTrig_leave_ai takes nothing returns nothing
set gg_trg_leave_ai = CreateTrigger( )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(0) )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(1) )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(2) )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(3) )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(4) )
call TriggerRegisterPlayerEventLeave( gg_trg_leave_ai, Player(5) )
call TriggerAddAction( gg_trg_leave_ai, function Trig_leave_ai_Actions )
endfunction
function Trig_Non_stuck_Conditions takes nothing returns boolean
return IsUnitType(GetEnteringUnit(),UNIT_TYPE_HERO)==true
endfunction
function Trig_Non_stuck_Actions takes nothing returns nothing
local unit c=GetEnteringUnit()
call Stuck(c)
set c=null
endfunction
//===========================================================================
function InitTrig_Non_stuck takes nothing returns nothing
set gg_trg_Non_stuck = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Non_stuck, gg_rct_up )
call TriggerRegisterEnterRectSimple( gg_trg_Non_stuck, gg_rct_down )
call TriggerRegisterEnterRectSimple( gg_trg_Non_stuck, gg_rct_right )
call TriggerRegisterEnterRectSimple( gg_trg_Non_stuck, gg_rct_left )
call TriggerAddCondition( gg_trg_Non_stuck, Condition( function Trig_Non_stuck_Conditions ) )
call TriggerAddAction( gg_trg_Non_stuck, function Trig_Non_stuck_Actions )
endfunction
function Trig_Upgrade_Actions takes nothing returns nothing
local unit c=GetEnteringUnit()
local integer x
if IsUnitType(c,UNIT_TYPE_HERO) and GetPlayerState(GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)>=15 then
set x=InputMsgI(GetOwningPlayer(c),"What do you want to upgrade?","Sakkat;Blade;CANCEL")
if x==1 then
call Upgrade(c,0)
elseif x==2 then
call Upgrade(c,1)
endif
if GetPlayerController(GetOwningPlayer(c))==MAP_CONTROL_COMPUTER then
call Upgrade(c,GetRandomInt(0,1))
endif
endif
set c=null
endfunction
//===========================================================================
function InitTrig_Upgrade takes nothing returns nothing
set gg_trg_Upgrade = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Upgrade, gg_rct_Taoist )
call TriggerAddAction( gg_trg_Upgrade, function Trig_Upgrade_Actions )
endfunction
//TESH.scrollpos=58
//TESH.alwaysfold=0
function Text takes unit u, string msg, real red, real green, real blue returns nothing
local texttag t = CreateTextTagUnitBJ( msg, u, 0, 12, red, green, blue, 0 )
call SetTextTagVelocityBJ( t, 64, 90 )
call SetTextTagPermanentBJ( t, false )
call SetTextTagLifespanBJ( t, 4.00 )
call SetTextTagFadepointBJ( t, 1.00 )
set t = null
endfunction
function PointLoss_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit u=GetHandleUnit(t,"u")
local integer point=GetHandleInt(t,"i")
if point==GetUnitUserData(u) then
call SetUnitUserData(u,0)
call Text(u,"Combo-loss!",100,25,20)
endif
set u=null
set t=null
endfunction
function PointLoss takes unit u returns nothing
local timer t=CreateTimer()
call SetHandleHandle(t,"u",u)
call SetHandleInt(t,"i",GetUnitUserData(u))
call TimerStart(t,10,false,function PointLoss_Child)
set t=null
endfunction
function Trig_Damage takes nothing returns nothing
local trigger t=GetTriggeringTrigger()
local unit c=GetHandleUnit(t,"c")
local unit u=GetHandleUnit(t,"u")
local integer data=GetUnitUserData(c)
local real hp=GetWidgetLife(u)
local integer z=GetRandomInt(1,10)
local string s
call FlushHandleLocals(t)
call DestroyTrigger(t)
call GibsBurst(GetUnitX(u),GetUnitY(u),'A003',0,2,400,0.5,1,60,120,0.1,0.4)
if z<3 then
set s="pain1.mp3"
elseif z<6 then
set s="pain2.mp3"
endif
set udg_attacked=u
set udg_attacker=c
// stuff
if data < 4 then
if data > 1 then
call Text(c,I2S(data+1)+"x",90,90,100)
endif
call SetUnitUserData(c,data+1)
call PointLoss(c)
else
call SetUnitUserData(c,0)
if hp<200 and GetRandomInt(0,2)==2 then
if GetRandomInt(0,1)==1 then
call AddTimedEffectTarget(c,"blood.mdl","weapon",4)
call Armless(u)
call Text(c,"Torned Arms!",100,10,10)
call AdjustPlayerStateBJ(6,GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)
else
call AddTimedEffectTarget(c,"blood.mdl","weapon",4)
call Legless(u)
call Text(c,"Torned Legs!",100,10,10)
call AdjustPlayerStateBJ(5,GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)
endif
elseif hp<100 then
call AddTimedEffectTarget(c,"blood.mdl","weapon",5)
call Headless(u)
call Text(c,"Ripped Head!",95,0,1)
call AdjustPlayerStateBJ(10,GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)
else
call UnitKO(u,c,2)
call Text(c,"Knocked!",0,60,100)
set s="fall1.mp3"
call AdjustPlayerStateBJ(1,GetOwningPlayer(c),PLAYER_STATE_RESOURCE_LUMBER)
endif
endif
// end stuff
call StartSoundUnit(s,c)
set u=null
set c=null
set t=null
endfunction
function Trig_Attack_Actions takes nothing returns nothing
local trigger t=CreateTrigger()
local unit c=GetAttacker()
local unit u=GetAttackedUnitBJ()
call SetHandleHandle(t,"c",c)
call SetHandleHandle(t,"u",u)
call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_DAMAGED)
call TriggerAddAction(t,function Trig_Damage)
set u=null
set c=null
set t=null
endfunction
//===========================================================================
function InitTrig_Attack takes nothing returns nothing
set gg_trg_Attack = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_Attack, function Trig_Attack_Actions )
endfunction
function Trig_Jumper_Actions takes nothing returns nothing
local unit u=GetEnteringUnit()
local real r=750
local location loc
if GetRandomInt(0,1)==0 then
set r=-750
endif
if IsUnitType(u,UNIT_TYPE_HERO) then
set loc=Location(GetUnitX(u)+r,GetUnitY(u)+r)
call LeapAttack(u,loc,50,1,120,false)
call StartSoundUnit("jump1.mp3",u)
endif
call RemoveLocation(loc)
set loc=null
set u=null
endfunction
//===========================================================================
function InitTrig_Jumper takes nothing returns nothing
set gg_trg_Jumper = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_Jumper, gg_rct_jumper1 )
call TriggerRegisterEnterRectSimple( gg_trg_Jumper, gg_rct_jumper2 )
call TriggerRegisterEnterRectSimple( gg_trg_Jumper, gg_rct_jumper3 )
call TriggerAddAction( gg_trg_Jumper, function Trig_Jumper_Actions )
endfunction
function Trig_Dodge_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A000'
endfunction
function Trig_Dodge_Actions takes nothing returns nothing
local unit c=GetSpellAbilityUnit()
local real angle
local real angle2
if GetRandomInt(0,1)==0 then
set angle = 90
set angle2 = -7
else
set angle = -90
set angle2 = 7
endif
call Push_angle(GetUnitFacing(c)+angle,c,40,30,0.04,"Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",angle2,1)
set c=null
endfunction
//===========================================================================
function InitTrig_Dodge takes nothing returns nothing
set gg_trg_Dodge = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Dodge, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Dodge, Condition( function Trig_Dodge_Conditions ) )
call TriggerAddAction( gg_trg_Dodge, function Trig_Dodge_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Leap_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A001'
endfunction
function Trig_Leap_Actions takes nothing returns nothing
local unit c=GetSpellAbilityUnit()
local location loc=GetSpellTargetLoc()
call LeapAttack(c,loc,50,1,120,false)
call StartSoundUnit("jump1.mp3",c)
call RemoveLocation(loc)
set loc=null
set c=null
endfunction
//===========================================================================
function InitTrig_Leap takes nothing returns nothing
set gg_trg_Leap = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Leap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Leap, Condition( function Trig_Leap_Conditions ) )
call TriggerAddAction( gg_trg_Leap, function Trig_Leap_Actions )
endfunction
function Trig_Dragon_Smash_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A002'
endfunction
function Trig_Dragon_Smash_Actions takes nothing returns nothing
local unit c=GetSpellAbilityUnit()
local unit u=GetSpellTargetUnit()
local effect x
local integer lvl=GetUnitAbilityLevel(c,'A002')
call UnitAddAbility(u,'Amrf')
call UnitRemoveAbility(u,'Amrf')
call SetUnitFacingToFaceUnitTimed(u,c,0)
call PauseUnit(u,true)
call SetUnitPathing(u,false)
call DestroyEffectBJ(AddSpecialEffectTargetUnitBJ("origin",u,"Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl"))
call SetUnitFlyHeightBJ(u,300,4000)
call TriggerSleepAction(0.3)
call IssueTargetOrder(c,"attackonce",u)
call TriggerSleepAction(0)
call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",u,"Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl"))
set x=AddSpecialEffectTargetUnitBJ("chest",u,"Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl" )
call Push_units(c,u,40,25,0.04,"Abilities\\Weapons\\ColdArrow\\ColdArrowMissile.mdl")
call SetUnitFlyHeightBJ(u,600,2000)
call TriggerSleepAction(0)
call SetUnitFlyHeightBJ(u,0,2000)
call TriggerSleepAction(0.3)
call GroupKO(u,400,1)
call UnitKO(u,c,2)
call TriggerSleepAction(0.3)
call GroupKO(u,500,1)
call DestroyEffect(x)
call UnitDamageTargetBJ(c,u,25+lvl*25,ATTACK_TYPE_MELEE,DAMAGE_TYPE_ENHANCED)
call SetUnitPathing(u,true)
call Stuck(u)
set c=null
set u=null
set x=null
endfunction
//===========================================================================
function InitTrig_Dragon_Smash takes nothing returns nothing
set gg_trg_Dragon_Smash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Smash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Dragon_Smash, Condition( function Trig_Dragon_Smash_Conditions ) )
call TriggerAddAction( gg_trg_Dragon_Smash, function Trig_Dragon_Smash_Actions )
endfunction
//TESH.scrollpos=30
//TESH.alwaysfold=0
function Trig_Dance_Conditions takes nothing returns boolean
return GetSpellAbilityId()=='A00F'
endfunction
function Dance_Spin takes unit c returns nothing
local group g=CreateGroup()
local unit u
local integer lvl=GetUnitAbilityLevel(c,'A00F')
call GroupEnumUnitsInRange(g,GetUnitX(c),GetUnitY(c),400,null)
call GroupRemoveUnit(g,c)
loop
set u=FirstOfGroup(g)
exitwhen u==null
if IsUnitType(u,UNIT_TYPE_HERO) and GetWidgetLife(u)>0 and not UnitHasBuffBJ(u,'Bvul') then
call DestroyEffect(AddSpecialEffectTargetUnitBJ("origin",u,"Abilities\\Weapons\\Axe\\AxeMissile.mdl"))
call AddTimedEffectTarget(c,"blood.mdl","weapon",2)
call GibsBurst(GetUnitX(u),GetUnitY(u),'A003',0,2,1500,0.7,1.5,75,150,0.2,0.5)
call UnitDamageTargetBJ(c,u,4+lvl*5,ATTACK_TYPE_MELEE,DAMAGE_TYPE_ENHANCED)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g=null
set u=null
endfunction
function Dance_Child takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit c=GetHandleUnit(t,"c")
local integer time=GetHandleInt(t,"time")
local real ang=GetHandleReal(t,"ang")
if ang>=360 then
set ang=0
endif
if time<=0 then
call PauseUnit(c,false)
call SetUnitPathing(c,true)
call SetUnitFlyHeight(c,0,1000)
call Stuck(c)
call ResetUnitAnimation(c)
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
else
set ang=ang+20
call SetUnitAnimation(c,"Attack Walk Stand Spin")
call MoveUnitToPolarProjection(c,30,ang)
call SetHandleReal(t,"ang",ang)
call SetHandleInt(t,"time",time-1)
call Dance_Spin(c)
endif
set c=null
set t=null
endfunction
function Dance_Start takes unit c, integer time returns nothing
local timer t=CreateTimer()
call PauseUnit(c,true)
call SetUnitPathing(c,false)
call SetUnitAnimation(c,"Attack Walk Stand Spin")
call SetUnitFlyHeight(c,200,500)
call SetHandleHandle(t,"c",c)
call SetHandleInt(t,"time",time)
call TimerStart(t,0.1,true,function Dance_Child)
set t=null
endfunction
function Trig_Dance_Actions takes nothing returns nothing
local unit c=GetSpellAbilityUnit()
call UnitAddAbility(c,'Amrf')
call UnitRemoveAbility(c,'Amrf')
call Dance_Start(c,50)
set c=null
endfunction
//===========================================================================
function InitTrig_Dance takes nothing returns nothing
set gg_trg_Dance = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Dance, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Dance, Condition( function Trig_Dance_Conditions ) )
call TriggerAddAction( gg_trg_Dance, function Trig_Dance_Actions )
endfunction