//##Start##
//====================================================================================================================================================================
constant function Caster_UnitId takes nothing returns integer
return 'e000' //// Caster Unit type rawcode (changes betwen maps, always use it inside '')
endfunction
constant function Caster_DefaultAttackType takes nothing returns attacktype
return ATTACK_TYPE_CHAOS // Default attack type used by the old functions and when you use 0 as DamageOptions
endfunction
constant function Caster_DefaultDamageType takes nothing returns damagetype
return DAMAGE_TYPE_UNIVERSAL // Default damage type used by the old functions and when you use 0 as DamageOptions
endfunction
constant function DamageTreeDetectorId takes nothing returns integer
return 'Aeat' /// The eat tree ability, don't need to change this rawcode unless you modiffied that ability in your map, in that case copy it, reset the copied one and use its rawcode here.
endfunction
constant function ChangeableFlyingHeightAllowerId takes nothing returns integer
return 'Amrf' /// Medivh's Crow form ability, don't need to change this rawcode unless you modiffied that ability in your map, in that case copy it, reset the copied one and use its rawcode here.
endfunction
constant function WaterDetectorId takes nothing returns integer
return 'Asb2' // The Royal Guard's submerge ability, don't need to change this rawcode unless you modiffied that ability in your map, in that case copy it, reset the copied one and use its rawcode here.
endfunction
//=================================================================================================
function CS_H2I takes handle h returns integer
return h
return 0
endfunction
//=================================================================================================
function CSCache takes nothing returns gamecache
if udg_cscache==null then
set udg_castervars[500]=0
call FlushGameCache(InitGameCache("CasterSystem.vx"))
set udg_cscache=InitGameCache("CasterSystem.vx")
endif
return udg_cscache
endfunction
function CS_Rawcode2Real takes integer i returns real
return i
return 0.
endfunction
function CS_LoadRawcodeFromReal takes integer n returns integer
return udg_castervars[n]
return 0
endfunction
//==================================================================================================
function AttachInt takes handle h, string label, integer x returns nothing
local string k=I2S(CS_H2I(h))
if x==0 then
call FlushStoredInteger(CSCache(),k,label)
else
call StoreInteger(CSCache(),k,label,x)
endif
endfunction
function AttachReal takes handle h, string label, real x returns nothing
local string k=I2S(CS_H2I(h))
if x==0 then
call FlushStoredReal(CSCache(),k,label)
else
call StoreReal(CSCache(),k,label,x)
endif
endfunction
function AttachBoolean takes handle h, string label, boolean x returns nothing
local string k=I2S(CS_H2I(h))
if not x then
call FlushStoredBoolean(CSCache(),k,label)
else
call StoreBoolean(CSCache(),k,label,x)
endif
endfunction
function AttachString takes handle h, string label, string x returns nothing
local string k=I2S(CS_H2I(h))
if x=="" then
call FlushStoredString(CSCache(),k,label)
else
call StoreString(CSCache(),k,label,x)
endif
endfunction
function AttachObject takes handle h, string label, handle x returns nothing
call AttachInt( h, label, CS_H2I(x) )
endfunction
//==================================================================================================
function GetAttachedInt takes handle h, string label returns integer
local real r=udg_castervars[500]
local integer i
local integer L
local string c
local string num
if (r>0) then
if SubString(label,0,1)=="#" then
set udg_castervars[500]=r-1
set i=0
set num=""
loop
set i=i+1
set c=SubString(label,i,i+1)
exitwhen (c==";") or (c=="")
set num=num+c
endloop
if c==";" then
return GetStoredInteger(CSCache(),I2S(CS_H2I(h))+";"+SubString(label,i+1,StringLength(label)+1),num)
endif
endif
endif
return GetStoredInteger(CSCache(), I2S(CS_H2I(h)), label)
endfunction
function GetAttachedReal takes handle h, string label returns real
return GetStoredReal(CSCache(),I2S(CS_H2I(h)),label)
endfunction
function GetAttachedString takes handle h, string label returns string
return GetStoredString(CSCache(),I2S(CS_H2I(h)),label)
endfunction
function GetAttachedBoolean takes handle h, string label returns boolean
return GetStoredBoolean(CSCache(),I2S(CS_H2I(h)),label)
endfunction
function GetAttachedObject takes handle h, string label returns handle
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedUnit takes handle h, string label returns unit
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedItem takes handle h, string label returns item
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedEffect takes handle h, string label returns effect
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedDestructable takes handle h, string label returns destructable
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTrigger takes handle h, string label returns trigger
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTimer takes handle h, string label returns timer
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedGroup takes handle h, string label returns group
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedTriggerAction takes handle h, string label returns triggeraction
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedLightning takes handle h, string label returns lightning
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedImage takes handle h, string label returns image
return GetAttachedInt(h,label)
return null
endfunction
function GetAttachedUbersplat takes handle h, string label returns ubersplat
return GetAttachedInt(h,label)
return null
endfunction
//============================================================================================================
// Attached Sets:
//
function FromSetElement takes string setn, integer index returns string
set udg_castervars[500]=udg_castervars[500]+1
return "#"+I2S(index)+";"+setn
endfunction
//============================================================================================================
function AttachedSetAddInt takes handle h, string setn, integer int returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))
local integer n
local integer x=GetStoredInteger(g,k,"#setnumberof;"+setn)
local integer y
if x==0 then
set y=GetStoredInteger(g,k,"#totalsets")+1
call StoreInteger(g,k,"#totalsets",y)
call StoreInteger(g,k,"#setnumberof;"+setn,y)
call StoreString(g,k,"#setName;"+I2S(y),setn)
endif
set k=k+";"+setn
if not HaveStoredInteger(g,k,"Pos"+I2S(int)) then
set n=GetStoredInteger(g,k,"n")+1
call StoreInteger(g,k,"n",n)
call StoreInteger(g,k,I2S(n),int)
call StoreInteger(g,k,"Pos"+I2S(int),n)
endif
set g=null
endfunction
function AttachedSetAddObject takes handle h, string setn, handle val returns nothing
call AttachedSetAddInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function AttachedSetHasInt takes handle h, string setn, integer int returns boolean
return HaveStoredInteger(CSCache(),I2S(CS_H2I(h))+";"+setn,"Pos"+I2S(int))
endfunction
//============================================================================================================
function AttachedSetHasObject takes handle h, string setn, handle val returns boolean
return AttachedSetHasInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function GetAttachedSetSize takes handle h, string setn returns integer
return GetStoredInteger(CSCache(),I2S(CS_H2I(h))+";"+setn,"n")
endfunction
//============================================================================================================
function AttachedSetRemInt takes handle h, string setn, integer int returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))+";"+setn
local integer n
local integer x
local integer y
if HaveStoredInteger(g,k,"Pos"+I2S(int)) then
set x=GetStoredInteger(g,k,"Pos"+I2S(int))
set n=GetStoredInteger(g,k,"n")
if x!=n then
set y=GetStoredInteger(g,k,I2S(n))
call StoreInteger(g,k,I2S(x),y)
call StoreInteger(g,k,"Pos"+I2S(y),x)
endif
call FlushStoredInteger(g,k,"Pos"+I2S(int))
call FlushStoredInteger(g,k,I2S(n))
call StoreInteger(g,k,"n",n-1)
endif
set g=null
endfunction
function AttachedSetRemObject takes handle h, string setn, handle val returns nothing
call AttachedSetRemInt(h,setn,CS_H2I(val))
endfunction
//============================================================================================================
function ClearAttachedSet takes handle h, string setn returns nothing
call FlushStoredMission(CSCache(),I2S(CS_H2I(h))+";"+setn)
endfunction
//==================================================================================================
function CleanAttachedVars takes handle h returns nothing
local gamecache g=CSCache()
local string k=I2S(CS_H2I(h))
local integer n=GetStoredInteger(g,k,"#totalsets")
local integer i=1
loop
exitwhen i>n
call FlushStoredMission(g,k+";"+GetStoredString(g,k,"#setName;"+I2S(i)))
set i=i+1
endloop
call FlushStoredMission(g, k )
set g=null
endfunction
//====================================================================================================================================================================
// Left For compatibility
//
function SpellEffectModelPath takes integer abilityid, effecttype t returns string
return GetAbilityEffectById(abilityid,t, 0)
endfunction
//====================================================================================================================================================================
function AddCasterFacing takes real fac returns unit
local unit m=CreateUnit( Player(15), Caster_UnitId(), 0 ,0 ,fac)
call UnitAddAbility(m, 'Aloc')
call UnitAddAbility(m, ChangeableFlyingHeightAllowerId())
call UnitRemoveAbility(m, ChangeableFlyingHeightAllowerId())
set udg_currentcaster=m
set m=null
return udg_currentcaster
endfunction
function AddCaster takes nothing returns unit
return AddCasterFacing(0)
endfunction
//====================================================================================================================================================================
function CreateCasters takes integer n returns nothing
local integer a=0
local unit c
set udg_castervars[100]=-1
set udg_castervars[101]=-1
set udg_castervars[102]=-1
set udg_castervars[103]=-1
set udg_castervars[104]=-1
loop
exitwhen a>=n
set c=AddCaster()
call GroupAddUnit( udg_casters, c)
set a=a+1
endloop
set c=null
call RemoveLocation(udg_sourcehack)
set udg_sourcehack=null
endfunction
//====================================================================================================================================================================
function GetACaster takes nothing returns unit
set udg_currentcaster=FirstOfGroup( udg_casters)
if udg_currentcaster == null then
set udg_currentcaster=AddCaster()
endif
call GroupRemoveUnit( udg_casters,udg_currentcaster)
call SetUnitState( udg_currentcaster, UNIT_STATE_MANA, 1000)
return udg_currentcaster
endfunction
//====================================================================================================================================================================
function RecicleCaster takes unit caster returns nothing
if not IsUnitDeadBJ(caster) then
call SetUnitOwner( caster, Player(15), true)
call SetUnitVertexColor( caster, 255,255,255,255)
call SetUnitScale( caster, 1,1,1)
call SetUnitTimeScale( caster, 1)
call SetUnitMoveSpeed( caster, 522)
call SetUnitFlyHeight( caster, 0,0)
call UnitAddAbility(caster, 'Aloc')
call SetUnitTurnSpeed( caster, 0.6)
call GroupAddUnit( udg_casters, caster)
endif
endfunction
function CasterWaitForEndCast takes nothing returns nothing
local unit caster=udg_currentcaster
local integer abilid=udg_currentabi
local real delay=udg_castervars[0]
local boolean activeability=(udg_castervars[1]>0)
loop
exitwhen GetUnitCurrentOrder(caster) == 0
call TriggerSleepAction(0)
endloop
if activeability then
call PolledWait(delay)
call UnitRemoveAbility( caster, abilid)
else
call UnitRemoveAbility( caster, abilid)
call PolledWait(delay)
endif
call RecicleCaster( caster)
set caster=null
endfunction
function RecicleCasterAfterCastEx takes unit caster, real delaytime, integer abilid, boolean activeability returns nothing
set udg_castervars[0]=delaytime
set udg_castervars[1]=IntegerTertiaryOp(activeability,1,0)
set udg_currentabi=abilid
set udg_currentcaster=caster
call ExecuteFunc("CasterWaitForEndCast" )
endfunction
function RecicleCasterAfterCast takes unit caster, integer abilid returns nothing
call RecicleCasterAfterCastEx(caster,udg_delayhack,abilid,false)
endfunction
//====================================================================================================================================================================
function PreloadAbility takes integer abilid returns integer
local unit u=FirstOfGroup(udg_casters)
if u==null then
set u=GetACaster()
call UnitAddAbility(u, abilid)
call UnitRemoveAbility(u, abilid)
call RecicleCaster( u)
else
call UnitAddAbility(u, abilid)
call UnitRemoveAbility(u, abilid)
endif
set u=null
return abilid
endfunction
//====================================================================================================================================================================
function CasterCastAbilityEx takes player owner, real x, real y, real z, integer abilid, integer level, string order, widget target, real delay returns unit
local unit caster=GetACaster()
local boolean done=false
call SetUnitOwner( caster, owner, false)
call UnitAddAbility( caster, abilid)
call SetUnitAbilityLevel(caster,abilid,level)
call SetUnitPosition( caster, x,y)
call SetUnitFlyHeight(caster,z,0)
if S2I(order) != 0 then
set done=IssueTargetOrderById( caster, S2I(order), target )
else
set done=IssueTargetOrder( caster, order, target )
endif
if (delay<=0) or not(done) then
call UnitRemoveAbility( caster, abilid)
call RecicleCaster( caster)
else
call RecicleCasterAfterCastEx(caster, delay, abilid, true)
endif
set udg_currentcaster=caster
set caster=null
return udg_currentcaster
endfunction
//====================================================================================================================================================================
function CasterCastAbilityExLoc takes player owner, location loc, real z, integer abilid, integer level, string order, widget target, real delay returns unit
return CasterCastAbilityEx(owner,GetLocationX(loc),GetLocationY(loc),z,abilid,level,order,target,delay)
endfunction
//====================================================================================================================================================================
function CasterCastAbilityLevel takes player owner, integer abilid, integer level, string order, widget target, boolean instant returns unit
local real x
local real y
local real d
if udg_sourcehack!=null then
set x=GetLocationX(udg_sourcehack)
set y=GetLocationY(udg_sourcehack)
else
set x=GetWidgetX(target)
set y=GetWidgetY(target)
endif
if instant then
set d=udg_delayhack+0.01
else
set d=0
endif
return CasterCastAbilityEx(owner,x,y,0,abilid,level,order,target,d)
endfunction
//====================================================================================================================================================================
function CasterCastAbility takes player owner, integer abilid, string order, widget target, boolean instant returns unit
return CasterCastAbilityLevel( owner, abilid, 1, order, target, instant )
endfunction
//====================================================================================================================================================================
function CasterCastAbilityPointEx takes player owner, real x1, real y1, real z1, integer abilid, integer level, string order, real x2, real y2, real delay returns unit
local unit caster=GetACaster()
call SetUnitOwner( caster, owner, false)
call UnitAddAbility( caster, abilid)
call SetUnitAbilityLevel(caster,abilid,level)
call SetUnitPosition( caster, x1, y1)
call SetUnitFlyHeight(caster,z1,0)
if S2I(order) != 0 then
if not IssuePointOrderById( caster, S2I(order), x2,y2 ) then
call IssueImmediateOrderById( caster, S2I(order) )
endif
else
if not IssuePointOrder( caster, order, x2,y2 ) then
call IssueImmediateOrder( caster, order )
endif
endif
if (delay<=0) then
call UnitRemoveAbility( caster, abilid)
call RecicleCaster( caster)
else
call RecicleCasterAfterCastEx(caster, delay, abilid, true)
endif
set udg_currentcaster=caster
set caster=null
return udg_currentcaster
endfunction
//====================================================================================================================================================================
function CasterCastAbilityPointExLoc takes player owner, location loc1, real z1, integer abilid, integer level, string order, location loc2, real delay returns unit
return CasterCastAbilityPointEx(owner,GetLocationX(loc1),GetLocationY(loc1),z1,abilid,level,order,GetLocationX(loc2),GetLocationY(loc2),delay)
endfunction
//====================================================================================================================================================================
function CasterCastAbilityLevelPoint takes player owner, integer abilid, integer level, string order, real x, real y, boolean instant returns unit
local real sx
local real sy
local real d
if udg_sourcehack!=null then
set sx=GetLocationX(udg_sourcehack)
set sy=GetLocationY(udg_sourcehack)
else
set sx=x
set sy=y
endif
if instant then
set d=0
else
set d=udg_delayhack+0.01
endif
return CasterCastAbilityPointEx(owner,sx,sy,0,abilid,level,order,x,y,d)
endfunction
function CasterCastAbilityPoint takes player owner, integer abilid, string order, real x, real y, boolean instant returns unit
return CasterCastAbilityLevelPoint(owner,abilid,1,order,x,y,instant)
endfunction
function CasterCastAbilityPointLoc takes player owner, integer abilid, string order, location loc, boolean instant returns unit
return CasterCastAbilityLevelPoint( owner, abilid, 1,order, GetLocationX(loc), GetLocationY(loc), instant )
endfunction
function CasterCastAbilityLevelPointLoc takes player owner, integer abilid, integer level, string order, location loc, boolean instant returns unit
return CasterCastAbilityLevelPoint( owner, abilid, level,order, GetLocationX(loc), GetLocationY(loc), instant )
endfunction
//====================================================================================================================================================================
function CasterUseAbilityStatic_Child takes nothing returns nothing
local unit caster=udg_currentcaster
local effect fx=bj_lastCreatedEffect
local integer abilid=udg_currentabi
call PolledWait( udg_castervars[1])
call DestroyEffect(fx)
call UnitRemoveAbility(caster,abilid)
call TriggerSleepAction(2)
call RecicleCaster(caster)
set fx=null
set caster=null
endfunction
function CasterUseAbilityLevelStatic takes player owner, string modelpath, integer abilityid, integer level, real duration, real x, real y returns unit
set udg_currentcaster=GetACaster()
call SetUnitPosition( udg_currentcaster, x, y)
set bj_lastCreatedEffect = AddSpecialEffectTarget( modelpath, udg_currentcaster,"origin" )
set udg_castervars[1]=duration
call SetUnitOwner( udg_currentcaster, owner, true)
call UnitAddAbility( udg_currentcaster, abilityid)
call SetUnitAbilityLevel( udg_currentcaster, abilityid, level)
set udg_currentabi=abilityid
call ExecuteFunc("CasterUseAbilityStatic_Child")
return udg_currentcaster
endfunction
function CasterUseAbilityStatic takes player owner, string modelpath, integer abilityid, real duration, real x, real y returns unit
return CasterUseAbilityLevelStatic(owner,modelpath,abilityid,1,duration,x,y)
endfunction
function CasterUseAbilityStaticLoc takes player owner, string modelpath, integer abilityid, real duration, location loc returns unit
return CasterUseAbilityLevelStatic(owner,modelpath,abilityid,1,duration, GetLocationX(loc), GetLocationY(loc))
endfunction
function CasterUseAbilityLevelStaticLoc takes player owner, string modelpath, integer abilityid, integer level,real duration, location loc returns unit
return CasterUseAbilityLevelStatic(owner,modelpath,abilityid,level,duration, GetLocationX(loc), GetLocationY(loc))
endfunction
//====================================================================================================================================================================
function CasterCastAbilityLevelGroup takes player owner, integer abilid, integer level,string order, group targetgroup, boolean instant returns nothing
local group affected
local unit tempunit
local unit caster=null
if bj_wantDestroyGroup then
set bj_wantDestroyGroup=false
set affected=targetgroup
else
set affected=CreateGroup()
call GroupAddGroup( targetgroup, affected)
endif
loop
set tempunit=FirstOfGroup(affected)
exitwhen tempunit == null
if instant then
if caster==null then
set caster=GetACaster()
call SetUnitOwner( caster, owner, false)
call UnitAddAbility( caster, abilid)
call SetUnitAbilityLevel( caster, abilid,level)
endif
if udg_sourcehack != null then
call SetUnitPositionLoc( caster, udg_sourcehack)
else
call SetUnitPosition( caster, GetUnitX(tempunit), GetUnitY(tempunit))
endif
if S2I(order) != 0 then
call IssueTargetOrderById( caster, S2I(order), tempunit )
else
call IssueTargetOrder( caster, order, tempunit )
endif
else
call CasterCastAbilityLevel( owner, abilid,level, order, tempunit, false)
endif
call GroupRemoveUnit(affected, tempunit)
endloop
if caster != null then
call UnitRemoveAbility( caster, abilid)
call RecicleCaster(caster)
endif
call DestroyGroup(affected)
set affected=null
set tempunit=null
set caster=null
endfunction
function CasterCastAbilityGroup takes player owner, integer abilid, string order, group targetgroup, boolean instant returns nothing
call CasterCastAbilityLevelGroup(owner,abilid,1,order,targetgroup,instant)
endfunction
//====================================================================================================================================================================
function CasterAOE_IsFilterEnemy takes nothing returns boolean
return IsUnitEnemy( GetFilterUnit(), bj_groupEnumOwningPlayer ) and not(IsUnitDeadBJ(GetFilterUnit()))
endfunction
function CasterAOE_IsFilterAlly takes nothing returns boolean
return IsUnitAlly( GetFilterUnit(), bj_groupEnumOwningPlayer ) and not(IsUnitDeadBJ(GetFilterUnit()))
endfunction
//====================================================================================================================================================================
function CasterCastAbilityLevelAOE takes player owner, integer abilid, integer level, string order, real x, real y, real radius, boolean goodeffect, boolean instant returns nothing
local boolexpr b
local group aoe=CreateGroup()
set bj_groupEnumOwningPlayer=owner
if goodeffect then
set b=Condition(function CasterAOE_IsFilterAlly)
else
set b=Condition(function CasterAOE_IsFilterEnemy)
endif
call GroupEnumUnitsInRange(aoe, x,y, radius, b)
set bj_wantDestroyGroup=true
call CasterCastAbilityLevelGroup( owner, abilid, level, order, aoe, instant)
call DestroyBoolExpr(b)
set b=null
set aoe=null
endfunction
function CasterCastAbilityAOE takes player owner, integer abilid, string order, real x, real y, real radius, boolean goodeffect, boolean instant returns nothing
call CasterCastAbilityLevelAOE(owner,abilid,1,order,x,y,radius,goodeffect,instant)
endfunction
function CasterCastAbilityAOELoc takes player owner, integer abilid, string order, location center, real radius, boolean goodeffect, boolean instant returns nothing
call CasterCastAbilityLevelAOE(owner, abilid,1, order, GetLocationX(center), GetLocationY(center), radius, goodeffect, instant)
endfunction
function CasterCastAbilityLevelAOELoc takes player owner, integer abilid, integer level, string order, location center, real radius, boolean goodeffect, boolean instant returns nothing
call CasterCastAbilityLevelAOE(owner, abilid,level, order, GetLocationX(center), GetLocationY(center), radius, goodeffect, instant)
endfunction
//====================================================================================================================================================================
function ResetSourceHack takes nothing returns nothing
call RemoveLocation(udg_sourcehack)
set udg_sourcehack=null
call DestroyTimer(GetExpiredTimer() )
endfunction
function CasterSetCastSource takes real x, real y returns nothing
set udg_sourcehack=Location(x,y)
call TimerStart(CreateTimer(),0,false,function ResetSourceHack)
endfunction
function CasterSetCastSourceLoc takes location loc returns nothing
call CasterSetCastSource( GetLocationX(loc), GetLocationY(loc) )
endfunction
function ResetDelayHack takes nothing returns nothing
set udg_delayhack=0
call DestroyTimer(GetExpiredTimer() )
endfunction
//====================================================================================================================================================================
function CasterSetRecycleDelay takes real Delay returns nothing
set udg_delayhack=Delay
call TimerStart(CreateTimer(),0,false,function ResetDelayHack)
endfunction
//====================================================================================================================================================================
function DamageTypes takes attacktype attT, damagetype dmgT returns integer
set udg_castervars[100] = CS_H2I(attT)
set udg_castervars[101] = CS_H2I(dmgT)
return 1
endfunction
function DamageException takes unittype Exception, real ExceptionFactor returns integer
set udg_castervars[102] = CS_H2I(Exception)
set udg_castervars[103] = ExceptionFactor
return 2
endfunction
function DamageOnlyTo takes unittype ThisUnitType returns integer
set udg_castervars[104] = CS_H2I(ThisUnitType)
return 4
endfunction
constant function DontDamageSelf takes nothing returns integer
return 8
endfunction
constant function DamageTrees takes nothing returns integer
return 16
endfunction
constant function DamageOnlyVisibles takes nothing returns integer
return 32
endfunction
function DamageOnlyEnemies takes nothing returns integer
set udg_castervars[105]=0
return 64
endfunction
function ForceDamageAllies takes nothing returns integer
set udg_castervars[105]=1
return 64
endfunction
function DamageOnlyAllies takes nothing returns integer
set udg_castervars[105]=2
return 64
endfunction
function DamageFactorAbility1 takes integer spellid, real factor returns integer
set udg_castervars[106]=CS_Rawcode2Real(spellid)
set udg_castervars[107]=factor
return 128
endfunction
function DamageFactorAbility2 takes integer spellid, real factor returns integer
set udg_castervars[108]=CS_Rawcode2Real(spellid)
set udg_castervars[109]=factor
return 256
endfunction
function DamageFactorAbility3 takes integer spellid, real factor returns integer
set udg_castervars[110]=CS_Rawcode2Real(spellid)
set udg_castervars[111]=factor
return 512
endfunction
function DamageIgnore takes unittype ThisUnitType returns integer
set udg_castervars[112] = CS_H2I(ThisUnitType)
return 1024
endfunction
//===============================================================================================
function CS_IsUnitVisible takes unit u, player p returns boolean
return IsUnitVisible(u,Player(bj_PLAYER_NEUTRAL_VICTIM)) or IsUnitVisible(u,p)
endfunction
//=================================================================================================
function GetDamageFactor takes unit u,attacktype a, damagetype d returns real
local real hp=GetWidgetLife(u)
local real r
local unit caster=GetACaster()
call UnitRemoveAbility(caster,'Aloc') //Otherwise the units would flee like crazy
call SetUnitPosition(caster,GetUnitX(u),GetUnitY(u))
call SetUnitOwner(caster,GetOwningPlayer(u),false)
call UnitDamageTarget(caster,u,0.01,true,false,a,d,null)
call RecicleCaster(caster)
set r= (hp-GetWidgetLife(u))*100
call SetWidgetLife(u,hp)
return r
endfunction
//======================================================================================================
// Fix for the unit type bugs from blizzard, amphibious units aren't considered ground for some reason
// so this considers any non flying unit as ground.
//
// Also heroes are resistant too, so in case UNIT_TYPE_RESISTANT is used it will return true in case the
// unit is a hero too.
//
function CS_IsUnitType takes unit u, unittype ut returns boolean
if (ut==UNIT_TYPE_GROUND) then
return not(IsUnitType(u,UNIT_TYPE_FLYING))
elseif (ut==UNIT_TYPE_RESISTANT) then
return IsUnitType(u,ut) or IsUnitType(u,UNIT_TYPE_HERO)
endif
return IsUnitType(u,ut)
endfunction
function GetDamageFactorByOptions takes unit hurter, unit target, integer DamageOptions returns real
local real r=1
local integer d=DamageOptions
if d>=1024 then
if CS_IsUnitType(target, ConvertUnitType(R2I(udg_castervars[112])) ) then
return 0.0
endif
set d=d-1024
endif
if d>=512 then
if GetUnitAbilityLevel(target,CS_LoadRawcodeFromReal(110))>0 then
set r=r*udg_castervars[111]
endif
set d=d-512
endif
if d>=256 then
if GetUnitAbilityLevel(target,CS_LoadRawcodeFromReal(108))>0 then
set r=r*udg_castervars[109]
endif
set d=d-256
endif
if d>=128 then
if GetUnitAbilityLevel(target,CS_LoadRawcodeFromReal(106))>0 then
set r=r*udg_castervars[107]
endif
set d=d-128
endif
if d>=64 then
if (udg_castervars[105]==0) and IsUnitAlly(target,GetOwningPlayer(hurter)) then
return 0.0
elseif (udg_castervars[105]==2) and IsUnitEnemy(target,GetOwningPlayer(hurter)) then
return 0.0
endif
set d=d-64
endif
if d>=32 then
set d=d-32
if not CS_IsUnitVisible(target,GetOwningPlayer(hurter)) then
return 0.0
endif
endif
if d>=16 then
set d=d-16
endif
if d>=8 then
set d=d-8
if hurter==target then
return 0.0
endif
endif
if d>=4 then
set d=d-4
if not CS_IsUnitType( target, ConvertUnitType(R2I(udg_castervars[104])) ) then
return 0.0
endif
endif
if d>=2 then
set d=d-2
if CS_IsUnitType( target, ConvertUnitType(R2I(udg_castervars[102])) ) then
set r=r*udg_castervars[103]
endif
endif
if d>=1 then
set d=d-1
set r=r*GetDamageFactor(target,ConvertAttackType(R2I(udg_castervars[100])),ConvertDamageType(R2I(udg_castervars[101])))
endif
return r
endfunction
//======================================================================================================================
// This used to be needed because in 1.17 UnitDamageTarget didn't consider the damagetype argument, this bug
// was fixed in 1.18, and we no longer need this function, left for compatibility.
//
function DamageUnitByTypes takes unit hurter, unit target, real dmg, attacktype attT, damagetype dmgT returns boolean
return UnitDamageTarget(hurter,target,dmg,true,false,attT,dmgT,null)
endfunction
//=============================================================================================================================
function DamageUnitByOptions takes unit hurter, unit target, real dmg, integer DamageOptions returns boolean
local real f=GetDamageFactorByOptions(hurter,target,DamageOptions)
if (f==0) then
return false
endif
return UnitDamageTarget(hurter,target,dmg*f,true,false,null,null,null)
endfunction
//=============================================================================================================================
function DamageUnit takes player hurter, real damage, unit victim returns boolean
local unit caster=GetACaster()
call UnitRemoveAbility(caster,'Aloc') //Otherwise the units would flee like crazy
call SetUnitPosition(caster,GetUnitX(victim),GetUnitY(victim))
call SetUnitOwner(caster,hurter,false)
call DamageUnitByTypes(caster,victim,damage,Caster_DefaultAttackType(),Caster_DefaultDamageType())
call RecicleCaster(caster)
return GetWidgetLife(victim)<=0 // I thought UnitDamageTarget returned true when it killed the unit, but nope, it returns true when it was able to do the damage.
endfunction
//====================================================================================================================================================================
function UnitDamageUnitTimed_Child takes nothing returns nothing
local real damage = udg_castervars[0]
local real damageperiod= udg_castervars[2]
local effect fx=bj_lastCreatedEffect
local timer t=CreateTimer()
local unit hurter=udg_currenthurter
local real next=0
local integer i=0
local real c
local unit target=udg_currentcaster
local damagetype dmgT=ConvertDamageType(R2I(udg_castervars[4]))
local attacktype attT=ConvertAttackType(R2I(udg_castervars[3]))
call TimerStart(t, udg_castervars[1]-0.01, false,null)
loop
if TimerGetElapsed(t) >= next then
exitwhen not UnitDamageTarget(hurter, target, damage,true,false, attT, dmgT,null)
exitwhen IsUnitDeadBJ(target)
set i=i+1
set next=i*damageperiod
endif
exitwhen (TimerGetRemaining(t) <= 0) or IsUnitDeadBJ(target)
call TriggerSleepAction(0)
endloop
call DestroyEffect(fx)
call DestroyTimer(t)
set t=null
set fx=null
set dmgT=null
set attT=null
endfunction
function UnitDamageUnitTimed takes unit hurter, real damageps, real damageperiod, real duration, unit target, string modelpath, string attachPointName, attacktype attT, damagetype dmgT returns nothing
local unit c=udg_currentcaster
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, target,attachPointName )
set udg_currentcaster=target
set udg_castervars[0]=damageps
set udg_castervars[1]=duration
set udg_castervars[2]=damageperiod
set udg_castervars[3]=CS_H2I(attT)
set udg_castervars[4]=CS_H2I(dmgT)
set udg_currenthurter=hurter
call ExecuteFunc("UnitDamageUnitTimed_Child")
set udg_currentcaster=c
set c=null
endfunction
//=============================================================================================================
// Left for compatibility
//
function DamageUnitTimedEx_Child takes nothing returns nothing
local real damage = udg_castervars[0]
local real damageperiod= udg_castervars[2]
local effect fx=bj_lastCreatedEffect
local timer t=CreateTimer()
local integer id=udg_currentabi
local real next=0
local integer i=0
local real c
local unit target=udg_currentcaster
call TimerStart(t, udg_castervars[1]-0.01, false,null)
loop
if TimerGetElapsed(t) >= next then
exitwhen DamageUnit( Player(id), damage, target)
set i=i+1
set next=i*damageperiod
endif
exitwhen (TimerGetRemaining(t) <= 0) or IsUnitDeadBJ(target)
call TriggerSleepAction(0)
endloop
call DestroyEffect(fx)
call DestroyTimer(t)
set t=null
set fx=null
endfunction
function DamageUnitTimedEx takes player owner, real damageps, real damageperiod, real duration, unit target, string modelpath, string attachPointName returns nothing
local unit c=udg_currentcaster
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, target,attachPointName )
set udg_currentcaster=target
set udg_castervars[0]=damageps
set udg_castervars[1]=duration
set udg_castervars[2]=damageperiod
set udg_currentabi=GetPlayerId( owner )
call ExecuteFunc("DamageUnitTimedEx_Child")
set udg_currentcaster=c
set c=null
endfunction
function DamageUnitTimed takes player owner, real damageps, real duration, unit target, string modelpath, string attachPointName returns nothing
call DamageUnitTimedEx(owner , damageps, 1, duration, target, modelpath, attachPointName )
endfunction
function SetDamageOptions_i takes gamecache g, integer n, integer DamageOptions returns nothing
local string key="DOPT"+I2S(n)
local integer d=DamageOptions
call StoreInteger(g,key,"value",d)
if d>=1024 then
call StoreInteger(g,key,"ign",R2I(udg_castervars[112]))
set d=d-1024
endif
if d>=512 then
call StoreInteger(g,key,"ab3",CS_LoadRawcodeFromReal(110))
call StoreReal(g,key,"fc3",udg_castervars[111])
set d=d-512
endif
if d>=256 then
call StoreInteger(g,key,"ab2",CS_LoadRawcodeFromReal(108))
call StoreReal(g,key,"fc2",udg_castervars[109])
set d=d-256
endif
if d>=128 then
call StoreInteger(g,key,"ab1",CS_LoadRawcodeFromReal(106))
call StoreReal(g,key,"fc1",udg_castervars[107])
set d=d-128
endif
if d >= 64 then
set d=d-64
call StoreInteger(g,key,"allied",R2I(udg_castervars[105]))
endif
if d >= 32 then
set d=d-32
endif
if d >= 16 then
set d=d-16
endif
if d >= 8 then
set d=d-8
endif
if d >= 4 then
call StoreInteger(g,key,"only",R2I(udg_castervars[104]))
set d=d-4
endif
if d >= 2 then
call StoreInteger(g,key,"excp",R2I(udg_castervars[102]))
call StoreReal(g,key,"excf",udg_castervars[103])
set d=d-2
endif
if d >= 1 then
call StoreInteger(g,key,"attT",R2I(udg_castervars[100]))
call StoreInteger(g,key,"dmgT",R2I(udg_castervars[101]))
endif
endfunction
function SetDamageOptions takes integer id, integer DamageOptions returns nothing
call SetDamageOptions_i(CSCache(),id,DamageOptions)
endfunction
function CreateDamageOptions takes integer DamageOptions returns integer
local gamecache g=CSCache()
local integer n=GetStoredInteger(g,"misc","DOPTn")+1
call StoreInteger(g,"misc","DOPTn",n)
call SetDamageOptions_i(g,n,DamageOptions)
set g=null
return n
endfunction
function DestroyDamageOptions takes integer id returns nothing
call FlushStoredMission(CSCache(),"DOPT"+I2S(id))
endfunction
function LoadDamageOptions takes integer id returns integer
local gamecache g=CSCache()
local string key="DOPT"+I2S(id)
local integer opt=GetStoredInteger(g,key,"value")
local integer v=opt
if v>=1024 then
set udg_castervars[112]= GetStoredInteger(g,key,"ign")
set v=v-1024
endif
if v>=512 then
set udg_castervars[110]=CS_Rawcode2Real(GetStoredInteger(g,key,"ab3"))
set udg_castervars[111]=GetStoredReal(g,key,"fc3")
set v=v-512
endif
if v>=256 then
set udg_castervars[108]=CS_Rawcode2Real(GetStoredInteger(g,key,"ab2"))
set udg_castervars[109]=GetStoredReal(g,key,"fc2")
set v=v-256
endif
if v>=128 then
set udg_castervars[106]=CS_Rawcode2Real(GetStoredInteger(g,key,"ab1"))
set udg_castervars[107]=GetStoredReal(g,key,"fc1")
set v=v-128
endif
if v >= 64 then
set v=v-64
set udg_castervars[105]= GetStoredInteger(g,key,"allied")
endif
if v >= 32 then
set v=v-32
endif
if v >= 16 then
set v=v-16
endif
if v >= 8 then
set v=v-8
endif
if v >= 4 then
set udg_castervars[104]=GetStoredInteger(g,key,"only")
set v=v-4
endif
if v >= 2 then
set udg_castervars[102]=GetStoredInteger(g,key,"excp")
set udg_castervars[103]=GetStoredReal(g,key,"excf")
set v=v-2
endif
if v >= 1 then
set udg_castervars[100]=GetStoredInteger(g,key,"attT")
set udg_castervars[101]=GetStoredInteger(g,key,"dmgT")
endif
set g=null
return opt
endfunction
//==================================================================================================
function IsDestructableTree_withcs takes destructable d returns boolean
local unit c=GetACaster()
local boolean b
local boolean i=IsDestructableInvulnerable(d)
local integer s=DamageTreeDetectorId()
if i then
call SetDestructableInvulnerable(d,false)
endif
call UnitAddAbility(c,s)
call SetUnitPosition(c,GetWidgetX(d),GetWidgetY(d))
set b=(IssueTargetOrder(c,"eattree",d))
call UnitRemoveAbility(c,s)
call RecicleCaster(c)
set c=null
if i then
call SetDestructableInvulnerable(d,true)
endif
return b
endfunction
function IsDestructableTree takes destructable d returns boolean
local gamecache g=CSCache()
local string k=I2S(GetDestructableTypeId(d))
local boolean b
if HaveStoredBoolean(g,"trees",k) then
set b=GetStoredBoolean(g,"trees",k)
set g=null
return b
else
set b=IsDestructableTree_withcs(d)
call StoreBoolean(g,"trees",k,b)
endif
set g=null
return b
endfunction
//===============================================================================================
function DamageDestructablesInCircleEnum takes nothing returns nothing
local destructable d=GetEnumDestructable()
local unit u=udg_currentcaster
if (GetWidgetLife(d)>0) and not(IsDestructableInvulnerable(d)) and (SquareRoot(Pow(GetDestructableX(d)-udg_castervars[200],2)+Pow(GetDestructableY(d)-udg_castervars[201],2)) <= udg_castervars[202]) then
call SetWidgetLife(d,GetWidgetLife(d)-udg_castervars[203])
endif
set udg_currentcaster=u
set u=null
set d=null
endfunction
function DamageDestructablesInCircle takes real x, real y, real radius, real dmg returns nothing
local rect r=Rect(x - radius,y - radius,x + radius,y + radius)
set udg_castervars[200]=x
set udg_castervars[201]=y
set udg_castervars[202]=radius
set udg_castervars[203]=dmg
call EnumDestructablesInRect(r,null,function DamageDestructablesInCircleEnum)
call RemoveRect(r)
set r=null
endfunction
function DamageDestructablesInCircleLoc takes location loc, real radius, real dmg returns nothing
call DamageDestructablesInCircle(GetLocationX(loc),GetLocationY(loc),radius,dmg)
endfunction
function DamageTreesInCircleEnum takes nothing returns nothing
local destructable d=GetEnumDestructable()
if (GetWidgetLife(d)>0) and not(IsDestructableInvulnerable(d)) and (SquareRoot(Pow(GetDestructableX(d)-udg_castervars[200],2)+Pow(GetDestructableY(d)-udg_castervars[201],2)) <= udg_castervars[202]) and (IsDestructableTree(d)) then
call KillDestructable(d)
endif
set d=null
endfunction
function DamageTreesInCircle takes real x, real y, real radius returns nothing
local rect r=Rect(x - radius,y - radius,x + radius,y + radius)
set udg_castervars[200]=x
set udg_castervars[201]=y
set udg_castervars[202]=radius
call EnumDestructablesInRect(r,null,function DamageTreesInCircleEnum)
call RemoveRect(r)
set r=null
endfunction
function DamageTreesInCircleLoc takes location loc, real radius returns nothing
call DamageTreesInCircle(GetLocationX(loc),GetLocationY(loc),radius)
endfunction
function DamageUnitGroupEx takes unit hurter, real damage, group targetgroup, integer DamageOptions returns nothing
local group affected
local unit p
if bj_wantDestroyGroup then
set bj_wantDestroyGroup=false
set affected=targetgroup
else
set affected=CreateGroup()
call GroupAddGroup( targetgroup, affected)
endif
loop
set p=FirstOfGroup(affected)
exitwhen p==null
call DamageUnitByOptions(hurter,p,damage,DamageOptions)
call GroupRemoveUnit(affected,p)
endloop
call DestroyGroup(affected)
set affected=null
set p=null
endfunction
function DamageUnitsInAOEEx takes unit hurter, real damage, real x, real y, real radius, boolean affectallied, integer DamageOptions returns nothing
local boolexpr b=null
local group aoe=CreateGroup()
local integer d=DamageOptions
set bj_groupEnumOwningPlayer=GetOwningPlayer(hurter)
if d>=1024 then
set d=d-1024
endif
if d>=512 then
set d=d-512
endif
if d>=256 then
set d=d-256
endif
if d>=128 then
set d=d-128
endif //#ancla##
if d>=64 then
if (udg_castervars[105]==2) then
set b=Condition(function CasterAOE_IsFilterAlly)
elseif (udg_castervars[105]==1) then
else
set b=Condition(function CasterAOE_IsFilterEnemy)
endif
set d=d-64
elseif not(affectallied) then
set b=Condition(function CasterAOE_IsFilterEnemy)
endif
if d>=32 then
set d=d-32
endif
if d>=16 then
call DamageTreesInCircle(x,y,radius)
endif
call GroupEnumUnitsInRange(aoe, x,y, radius, b)
set bj_wantDestroyGroup=true
call DamageUnitGroupEx( hurter, damage, aoe,DamageOptions)
call DestroyBoolExpr(b)
set b=null
set aoe=null
endfunction
function DamageUnitsInAOEExLoc takes unit hurter, real damage, location loc, real radius, boolean affectallied, integer DamageOptions returns nothing
call DamageUnitsInAOEEx(hurter,damage, GetLocationX(loc), GetLocationY(loc), radius, affectallied,DamageOptions)
endfunction
function DamageUnitGroup takes player hurter, real damage, group targetgroup returns nothing
local unit caster=GetACaster()
call UnitRemoveAbility(caster,'Aloc') //Otherwise the units would flee like crazy
call SetUnitOwner(caster,hurter,false)
call DamageUnitGroupEx(caster,damage,targetgroup,0)
call RecicleCaster(caster)
set caster=null
endfunction
//====================================================================================================================================================================
function DamageUnitsInAOE takes player hurter, real damage, real x, real y, real radius, boolean affectallied returns nothing
local unit caster=GetACaster()
call UnitRemoveAbility(caster,'Aloc') //Otherwise the units would flee like crazy
call SetUnitOwner(caster,hurter,false)
call DamageUnitsInAOEEx(caster,damage,x,y,radius,affectallied,0)
call RecicleCaster(caster)
set caster=null
endfunction
function DamageUnitsInAOELoc takes player hurter, real damage, location loc, real radius, boolean affectallied returns nothing
call DamageUnitsInAOE( hurter, damage, GetLocationX(loc), GetLocationY(loc), radius, affectallied)
endfunction
//====================================================================================================================================================================
function AddAreaDamagerForUnit_Child takes nothing returns nothing
local real D
local real damageps = udg_castervars[0]
local real area = udg_castervars[2]
local real damageperiod = udg_castervars[3]
local real excd=udg_castervars[8]
local boolean affectallies = (udg_castervars[4]>=1)
local boolean onlyallies = (udg_castervars[4]==2)
local boolean self = (udg_castervars[5]==1)
local effect fx = bj_lastCreatedEffect
local unit hurter=udg_currenthurter
local unit fire = udg_currentcaster
local player owner = GetOwningPlayer(fire)
local timer t = CreateTimer()
local real next = 0
local integer a = 0
local group inrange = CreateGroup()
local string c
local string art=bj_lastPlayedMusic
local string attach=""
local unit picked
local boolean recicled=false
local unittype only=null
local unittype ign=null
local unittype exce=null
local attacktype attT
local damagetype dmgT
local boolean trees=(udg_castervars[11]==1)
local boolean inv=(udg_castervars[12]==1)
local integer a1=0
local integer a2=0
local integer a3=0
local real f1=udg_castervars[107]
local real f2=udg_castervars[109]
local real f3=udg_castervars[111]
if f1!=1 then
set a1=CS_LoadRawcodeFromReal(106)
endif
if f2!=1 then
set a2=CS_LoadRawcodeFromReal(108)
endif
if f3!=1 then
set a3=CS_LoadRawcodeFromReal(110)
endif
if udg_castervars[112]!=-1 then
set ign=ConvertUnitType(R2I(udg_castervars[112]))
endif
if udg_castervars[6]!=-1 then
set only=ConvertUnitType(R2I(udg_castervars[6]))
endif
if udg_castervars[7]!=-1 then
set exce=ConvertUnitType(R2I(udg_castervars[7]))
endif
if udg_castervars[9]!=-1 then
set attT=ConvertAttackType(R2I(udg_castervars[9]))
else
set attT=Caster_DefaultAttackType()
endif
if udg_castervars[10]!=-1 then
set dmgT=ConvertDamageType(R2I(udg_castervars[10]))
else
set dmgT=Caster_DefaultDamageType()
endif
loop
set c=SubString(art,a,a+1)
exitwhen c=="!" or c==""
set attach=attach+c
set a=a+1
endloop
set art=SubString(art,a+1,10000)
call TimerStart(t, udg_castervars[1]-0.01, false,null)
set a=0
loop
if IsUnitInGroup( fire, udg_casters) then
set recicled=true
call GroupRemoveUnit( udg_casters,fire)
endif
exitwhen recicled
if TimerGetElapsed(t) >= next then
set a=a+1
set next=a*damageperiod
call GroupEnumUnitsInRange(inrange, GetUnitX(fire), GetUnitY(fire), area, null )
if trees then
call DamageTreesInCircle(GetUnitX(fire), GetUnitY(fire), area)
endif
loop
set picked=FirstOfGroup(inrange)
exitwhen picked==null
if (self or picked!=hurter) and not(IsUnitDeadBJ(picked)) and ( (affectallies and (not(onlyallies) or IsUnitAlly(picked, owner) ) )or IsUnitEnemy(picked, owner) ) and (only==null or CS_IsUnitType(picked,only)) and (ign==null or not(CS_IsUnitType(picked,ign))) then
set D=damageps
if (exce!=null) and CS_IsUnitType(picked,exce) then
set D=D*excd
endif
if inv and not(CS_IsUnitVisible(picked,owner)) then
set D=0
endif
if (a1!=0) and (GetUnitAbilityLevel(picked,a1)>0) then
set D=D*f1
endif
if (a2!=0) and (GetUnitAbilityLevel(picked,a2)>0) then
set D=D*f2
endif
if (a3!=0) and (GetUnitAbilityLevel(picked,a3)>0) then
set D=D*f3
endif
if D!=0 then
call UnitDamageUnitTimed(hurter,D,damageperiod,damageperiod,picked,art,attach,attT,dmgT)
endif
endif
call GroupRemoveUnit(inrange,picked)
endloop
endif
exitwhen TimerGetRemaining(t)<=0
call TriggerSleepAction(0)
endloop
call DestroyGroup(inrange)
call DestroyEffect(fx)
call TriggerSleepAction(2)
call RecicleCaster(fire)
call DestroyTimer(t)
set inrange=null
set fire=null
set t=null
set owner=null
set fx=null
set picked=null
set hurter=null
set only=null
set ign=null
set exce=null
set attT=null
set dmgT=null
endfunction
function AddAreaDamagerForUnit takes unit hurter, string modelpath, string targetart, string targetattach, real x, real y, real damage , real damageperiod, real duration, real area, boolean affectallies, integer DamageOptions returns unit
local string s=bj_lastPlayedMusic
local integer v=DamageOptions
set bj_lastPlayedMusic=targetattach+"!"+targetart
set udg_currentcaster=GetACaster()
call SetUnitPosition( udg_currentcaster, x, y)
set bj_lastCreatedEffect = AddSpecialEffectTarget( modelpath, udg_currentcaster,"origin" )
set udg_castervars[0]=damage
set udg_castervars[1]=duration
set udg_castervars[2]=area
set udg_castervars[3]=damageperiod
if v >= 1024 then
set v=v-1024
else
set udg_castervars[112]=-1
endif
if v >= 512 then
set v=v-512
else
set udg_castervars[111]=0
endif
if v >= 256 then
set v=v-256
else
set udg_castervars[109]=0
endif
if v >= 128 then
set v=v-128
else
set udg_castervars[107]=0
endif
if v >= 64 then
set v=v-64
set udg_castervars[4]=udg_castervars[105]
else
set udg_castervars[4]=IntegerTertiaryOp(affectallies,1,0)
endif
if v >= 32 then
set udg_castervars[12]=1
set v=v-32
else
set udg_castervars[12]=0
endif
if v >= 16 then
set udg_castervars[11]=1
set v=v-16
else
set udg_castervars[11]=0
endif
if v >= 8 then
set udg_castervars[5]=0
set v=v-8
else
set udg_castervars[5]=1
endif
if v >= 4 then
set udg_castervars[6]=udg_castervars[104]
set v=v-4
else
set udg_castervars[6]=-1
endif
if v >= 2 then
set udg_castervars[7]=udg_castervars[102]
set udg_castervars[8]=damage*udg_castervars[103]
set v=v-2
else
set udg_castervars[7]=-1
set udg_castervars[8]=-1
endif
if v >= 1 then
set udg_castervars[9]=udg_castervars[100]
set udg_castervars[10]=udg_castervars[101]
else
set udg_castervars[9]=-1
set udg_castervars[10]=-1
endif
set udg_currenthurter=hurter
call SetUnitOwner( udg_currentcaster, GetOwningPlayer(hurter), true)
call ExecuteFunc("AddAreaDamagerForUnit_Child")
set bj_lastPlayedMusic=s
return udg_currentcaster
endfunction
function AddAreaDamagerForUnitLoc takes unit hurter, string modelpath, string targetart, string targetattach, location loc, real damage , real damageperiod, real duration, real area, boolean affectallies, integer DamageOptions returns unit
return AddAreaDamagerForUnit(hurter,modelpath,targetart,targetattach,GetLocationX(loc),GetLocationY(loc), damage , damageperiod, duration, area,affectallies, DamageOptions)
endfunction
function AddDamagingEffectEx takes player owner, string modelpath, string targetart, string targetattach, real x, real y, real damage , real damageperiod, real duration, real area, boolean affectallies returns unit
local string s=bj_lastPlayedMusic
set bj_lastPlayedMusic=targetattach+"!"+targetart
set udg_currentcaster=GetACaster()
call SetUnitPosition( udg_currentcaster, x, y)
set bj_lastCreatedEffect = AddSpecialEffectTarget( modelpath, udg_currentcaster,"origin" )
set udg_castervars[0]=damage
set udg_castervars[1]=duration
set udg_castervars[2]=area
set udg_castervars[3]=damageperiod
set udg_castervars[4]=IntegerTertiaryOp(affectallies,1,0)
set udg_castervars[5]=1
set udg_castervars[6]=-1
set udg_castervars[7]=-1
set udg_castervars[8]=-1
set udg_castervars[9]=-1
set udg_castervars[10]=-1
set udg_castervars[107]=0
set udg_castervars[109]=0
set udg_castervars[111]=0
set udg_castervars[112]=-1
set udg_currenthurter=udg_currentcaster
call SetUnitOwner( udg_currentcaster, owner, true)
call ExecuteFunc("AddAreaDamagerForUnit_Child")
set bj_lastPlayedMusic=s
return udg_currentcaster
endfunction
function AddDamagingEffectExLoc takes player owner, string modelpath, string targetart, string targetattach, location loc, real damage , real damageperiod, real duration, real area, boolean affectallies returns unit
return AddDamagingEffectEx( owner, modelpath, targetart, targetattach, GetLocationX(loc), GetLocationY(loc), damage , damageperiod, duration, area, affectallies )
endfunction
function AddDamagingEffect takes player owner, string modelpath, real x, real y, real damageps , real duration, real area, boolean affectallies returns unit
return AddDamagingEffectEx( owner, modelpath, "", "", x, y, damageps , 1, duration, area, affectallies )
endfunction
function AddDamagingEffectLoc takes player owner, string modelpath, location loc, real damageps , real duration, real area, boolean affectallies returns unit
return AddDamagingEffectEx( owner, modelpath, "", "", GetLocationX(loc), GetLocationY(loc), damageps ,1, duration, area, affectallies)
endfunction
//============================================================================================================
function UnitMoveToAsProjectileGen takes unit m, real arc, real x2, real y2, unit target, real z2 returns nothing
//
// The internal projectile system used by all the projectile functions
//
local real x1=GetUnitX(m)
local real y1=GetUnitY(m)
local real acel=arc*1600
local real speed=GetUnitMoveSpeed(m)
local real z1=GetUnitFlyHeight(m)
local real d
local real d1
local real d2
local real t
local real vel
local real dif=0
local boolean tounit= (target!=null)
local boolean b=false
local boolean mode=false
if tounit then
set x2=GetUnitX(target)
set y2=GetUnitY(target)
set z2=GetUnitFlyHeight(target)+z2
endif
set mode=(z2>z1)
set d=SquareRoot(Pow(x2-x1,2)+Pow(y2-y1,2))
set d1=1000000
set d2=0
set t=d/speed
if t==0 then
set t=0.001
endif
set vel=(z2-z1+0.5*acel*t*t)/t
call SetUnitFacing( m, Atan2BJ(y2 - y1, x2 - x2) )
call IssuePointOrder( m, "move", x2,y2)
set t=0
loop
set d2=d1
if tounit then
if IsUnitDeadBJ(target) then
set tounit=false
else
set x2=GetUnitX(target)
set y2=GetUnitY(target)
endif
endif
set d1=SquareRoot(Pow(x2-GetUnitX(m),2)+Pow(y2-GetUnitY(m),2))
exitwhen b or d1==0
set b=(d1<=speed*(t-dif))
exitwhen (mode and b) or (GetUnitCurrentOrder(m) != OrderId("move"))
if tounit then
call IssuePointOrder( m, "move", x2,y2)
endif
set dif=t
if dif==0.001 then
set t=0.1
else
set t= (d-d1)/speed
endif
set t= 2*t-dif
call SetUnitFlyHeight( m, z1+(vel*t-0.5*acel*t*t), RAbsBJ( vel-acel*(t+dif)/2) )
set t=(t+dif)/2
call TriggerSleepAction(0)
endloop
if tounit then
set x2=GetUnitX(target)
set y2=GetUnitY(target)
endif
call SetUnitFlyHeight( m,z2,0)
call SetUnitPosition(m,x2,y2)
endfunction
function UnitMoveToAsProjectile takes unit m, real arc, real x2, real y2, real z2 returns nothing
call UnitMoveToAsProjectileGen(m, arc,x2,y2,null,z2)
endfunction
//============================================================================================================
function ProjectileLaunchEx takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc,real x1, real y1, real z1, real x2, real y2, real z2 returns nothing
local unit m=AddCasterFacing( Atan2BJ(y2 - y1, x2 - x1) )
local effect fx=null
call SetUnitPosition( m, x1,y1)
call SetUnitScale( m, scale, scale, scale)
call SetUnitVertexColor(m, red, green, blue, alpha)
call SetUnitMoveSpeed(m, speed)
call SetUnitFlyHeight( m, z1, 0)
set fx= AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, owner, true)
call UnitMoveToAsProjectile(m, arc, x2, y2, z2)
call DestroyEffect(fx)
call ExplodeUnitBJ(m)
set owner=null
set fx=null
set m=null
endfunction
function ProjectileLaunchExLoc takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, location loc1, real z1, location loc2, real z2 returns nothing
call ProjectileLaunchEx( owner, modelpath, scale, red, green, blue, alpha, speed, arc,GetLocationX(loc1), GetLocationY(loc1), z1, GetLocationX(loc2), GetLocationY(loc2), z2)
endfunction
//============================================================================================================
function ProjectileLaunch takes string modelpath, real speed, real arc,real x1, real y1, real z1, real x2, real y2, real z2 returns nothing
call ProjectileLaunchEx( Player(15), modelpath, 1, 255, 255, 255, 255, speed, arc,x1,y1,z1,x2,y2,z2)
endfunction
function ProjectileLaunchLoc takes string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2 returns nothing
call ProjectileLaunchExLoc( Player(15), modelpath, 1,255,255,255,255,speed,arc,loc1,z1,loc2,z2)
endfunction
//============================================================================================================
function DamagingProjectileLaunchAOE_Child takes nothing returns nothing
local unit m=udg_currentcaster
local effect fx=bj_lastCreatedEffect
local real x2=udg_castervars[0]
local real y2=udg_castervars[1]
local real aoeradius=udg_castervars[3]
local real damage=udg_castervars[4]
local boolean affectallied=bj_isUnitGroupInRectResult
local integer V=CreateDamageOptions(R2I(udg_castervars[5]))
local unit hurter=udg_currenthurter
call UnitMoveToAsProjectile(m, bj_meleeNearestMineDist, udg_castervars[0], udg_castervars[1], udg_castervars[2])
call DestroyEffect(fx)
call DamageUnitsInAOEEx(hurter,damage,x2,y2,aoeradius,affectallied,LoadDamageOptions(V))
call DestroyDamageOptions(V)
call ExplodeUnitBJ(m)
set m=null
set fx=null
endfunction
function DamagingProjectileLaunchAOE takes unit hurter, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2, real aoeradius, real damage, boolean affectallied, integer DamageOptions returns unit
local unit m=AddCasterFacing( Atan2BJ(y2 - y1, x2 - x1) )
call SetUnitPosition(m, x1,y1)
call SetUnitMoveSpeed( m, speed)
call SetUnitFlyHeight( m, z1, 0)
set udg_currentcaster=m
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, GetOwningPlayer(hurter), true)
set bj_meleeNearestMineDist = arc
set udg_castervars[0] = x2
set udg_castervars[1] = y2
set udg_castervars[2] = z2
set udg_castervars[3] =aoeradius
set udg_castervars[4] =damage
set udg_castervars[5] =DamageOptions
set udg_currenthurter=hurter
call ExecuteFunc("DamagingProjectileLaunchAOE_Child")
set m=null
return udg_currentcaster
endfunction
function DamagingProjectileLaunchAOELoc takes unit hurter, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2, real aoeradius, real damage, boolean affectallied, integer DamageOptions returns unit
return DamagingProjectileLaunchAOE(hurter,modelpath,speed,arc,GetLocationX(loc1),GetLocationY(loc1),z1,GetLocationX(loc2),GetLocationY(loc2),z2, aoeradius, damage, affectallied, DamageOptions )
endfunction
function ProjectileLaunchDamage takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2, real aoeradius, real damage, boolean affectallied returns unit
local unit m=AddCasterFacing( Atan2BJ(y2 - y1, x2 - x1) )
call SetUnitPosition(m, x1,y1)
call SetUnitMoveSpeed( m, speed)
call SetUnitFlyHeight( m, z1, 0)
set udg_currentcaster=m
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, owner, true)
set bj_meleeNearestMineDist = arc
set udg_castervars[0] = x2
set udg_castervars[1] = y2
set udg_castervars[2] = z2
set udg_castervars[3] =aoeradius
set udg_castervars[4] =damage
set udg_castervars[5] =0
set udg_castervars[6]=1
set udg_castervars[7]=-1
set udg_castervars[8]=-1
set udg_castervars[9]=-1
set udg_castervars[10]=-1
set udg_castervars[11]=-1
set bj_isUnitGroupInRectResult=affectallied
set udg_currenthurter=m
call ExecuteFunc("DamagingProjectileLaunchAOE_Child")
set m=null
return udg_currentcaster
endfunction
function ProjectileLaunchDamageLoc takes player owner, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2, real aoeradius, real damage, boolean affectallied returns unit
return ProjectileLaunchDamage( owner, modelpath, speed, arc, GetLocationX(loc1), GetLocationY(loc1), z1, GetLocationX(loc2), GetLocationY(loc2), z2, aoeradius, damage, affectallied)
endfunction
//============================================================================================================
function ProjectileLaunchKill_Child takes nothing returns nothing
local unit m=udg_currentcaster
local effect fx=bj_lastCreatedEffect
local real x2=udg_castervars[0]
local real y2=udg_castervars[1]
call UnitMoveToAsProjectile(m, bj_meleeNearestMineDist, udg_castervars[0], udg_castervars[1], udg_castervars[2])
call ExplodeUnitBJ(m)
call DestroyEffect( fx)
set m=null
set fx=null
endfunction
function ProjectileLaunchKill takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2 returns unit
local unit m=AddCasterFacing( Atan2BJ(y2 - y1, x2 - x1) )
call SetUnitPosition(m, x1,y1)
call SetUnitMoveSpeed( m, speed)
call SetUnitFlyHeight( m, z1, 0)
set udg_currentcaster=m
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, owner, true)
set bj_meleeNearestMineDist = arc
set udg_castervars[0] = x2
set udg_castervars[1] = y2
set udg_castervars[2] = z2
call ExecuteFunc("ProjectileLaunchKill_Child")
set m=null
return udg_currentcaster
endfunction
function ProjectileLaunchKillLoc takes player owner, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2 returns unit
return ProjectileLaunchKill( owner, modelpath, speed, arc, GetLocationX(loc1), GetLocationY(loc1), z1, GetLocationX(loc2), GetLocationY(loc2), z2)
endfunction
//====================================================================================================================================================================
function UnitMoveToUnitAsProjectile takes unit m, real arc, unit target, real zoffset returns nothing
call UnitMoveToAsProjectileGen(m, arc,0,0,target,zoffset)
endfunction
//====================================================================================================================================================================
function ProjectileLaunchToUnitEx takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset returns nothing
local unit m=AddCasterFacing( Atan2BJ(GetUnitY(target) - y1, GetUnitX(target) - x1) )
local effect fx=null
call SetUnitPosition( m, x1,y1)
call SetUnitMoveSpeed(m, speed)
call SetUnitFlyHeight( m, z1, 0)
call SetUnitScale( m, scale, scale, scale)
call SetUnitVertexColor(m, red, green, blue, alpha)
set fx=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m , owner, true)
call UnitMoveToUnitAsProjectile( m, arc, target, zoffset )
call DestroyEffect(fx)
call ExplodeUnitBJ(m)
set m=null
set fx=null
endfunction
function ProjectileLaunchToUnitExLoc takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, location loc1, real z1, unit target, real zoffset returns nothing
call ProjectileLaunchToUnitEx( owner, modelpath, scale, red, green, blue, alpha, speed, arc, GetLocationX(loc1),GetLocationY(loc1), z1, target, zoffset)
endfunction
function ProjectileLaunchToUnit takes string modelpath, real speed, real arc,real x1, real y1, real z1, unit target, real zoffset returns nothing
call ProjectileLaunchToUnitEx( Player(15), modelpath, 1, 255,255,255,255,speed,arc,x1,y1,z1,target,zoffset)
endfunction
function ProjectileLaunchToUnitLoc takes string modelpath, real speed, real arc, location loc1, real z1, unit target, real zoffset returns nothing
call ProjectileLaunchToUnitExLoc( Player(15), modelpath, 1, 255,255,255,255, speed, arc, loc1, z1, target,zoffset)
endfunction
//====================================================================================================================================================================
function DamagingProjectileLaunchTarget_Child takes nothing returns nothing
local unit m=udg_currentcaster
local unit target=bj_meleeNearestMine
local effect fx=bj_lastCreatedEffect
local real damage=udg_castervars[4]
local damagetype dmgT=ConvertDamageType(R2I(udg_castervars[6]))
local attacktype attT=ConvertAttackType(R2I(udg_castervars[5]))
local unit hurter=udg_currenthurter
call UnitMoveToUnitAsProjectile(m, bj_meleeNearestMineDist, target, udg_castervars[2])
call DestroyEffect( fx)
call DamageUnitByTypes(hurter,target,damage,attT,dmgT)
call ExplodeUnitBJ(m)
set m=null
set hurter=null
set target=null
set fx=null
set dmgT=null
set attT=null
endfunction
function DamagingProjectileLaunchTarget takes unit hurter, string modelpath, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset, real damage, attacktype attT, damagetype dmgT returns unit
local unit m=AddCasterFacing( Atan2BJ(GetUnitY(target) - y1, GetUnitX(target) - x1) )
call SetUnitPosition(m, x1,y1)
call SetUnitMoveSpeed( m, speed)
call SetUnitFlyHeight( m, z1, 0)
set udg_currentcaster=m
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, GetOwningPlayer(hurter), true)
set bj_meleeNearestMineDist = arc
set udg_castervars[2]= zoffset
set bj_meleeNearestMine=target
set udg_castervars[4]=damage
set udg_castervars[5]=CS_H2I(attT)
set udg_castervars[6]=CS_H2I(dmgT)
set udg_currenthurter=hurter
call ExecuteFunc("DamagingProjectileLaunchTarget_Child")
set m=null
return udg_currentcaster
endfunction
function DamagingProjectileLaunchTargetLoc takes unit hurter, string modelpath, real speed, real arc, location loc, real z1, unit target, real zoffset, real damage, attacktype attT, damagetype dmgT returns unit
return DamagingProjectileLaunchTarget(hurter,modelpath,speed,arc,GetLocationX(loc),GetLocationY(loc), z1, target, zoffset, damage, attT, dmgT)
endfunction
function ProjectileLaunchToUnitDamage takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset, real damage returns unit
local unit m=AddCasterFacing( Atan2BJ(GetUnitY(target) - y1, GetUnitX(target) - x1) )
call SetUnitPosition(m, x1,y1)
call SetUnitMoveSpeed( m, speed)
call SetUnitFlyHeight( m, z1, 0)
set udg_currentcaster=m
set bj_lastCreatedEffect=AddSpecialEffectTarget( modelpath, m,"origin" )
call SetUnitOwner( m, owner, true)
set bj_meleeNearestMineDist = arc
set udg_castervars[2]= zoffset
set bj_meleeNearestMine=target
set udg_castervars[4]=damage
set udg_castervars[5]=CS_H2I(Caster_DefaultAttackType())
set udg_castervars[6]=CS_H2I(Caster_DefaultDamageType())
set udg_currenthurter=m
call ExecuteFunc("DamagingProjectileLaunchTarget_Child")
set m=null
return udg_currentcaster
endfunction
function ProjectileLaunchToUnitDamageLoc takes player owner, string modelpath, real speed, real arc, location loc1, real z1, unit target, real zoffset, real damage returns unit
return ProjectileLaunchToUnitDamage( owner, modelpath, speed, arc,GetLocationX(loc1),GetLocationY(loc1),z1,target,zoffset,damage)
endfunction
//==================================================================================================
function IsPointWater takes real x, real y returns boolean
return IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not(IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING))
endfunction
function IsPointWaterLoc takes location loc returns boolean
return IsPointWater(GetLocationX(loc),GetLocationY(loc))
endfunction
//==================================================================================================
function IsUnitSpellImmune takes unit u returns boolean
return IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)
endfunction
function IsUnitImmuneToPhisical takes unit u returns boolean
return (GetDamageFactor(u,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_DEMOLITION)==0)
endfunction
function IsUnitInvulnerable takes unit u returns boolean
return (GetDamageFactor(u,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL)==0)
endfunction
//##End##
//**START**
//=============================================================================================
// Return Bug Exploiters
//=============================================================================================
function HandleToUnit takes handle h returns unit
return h
endfunction
function HandleToInt takes handle h returns integer
return h
return 0
endfunction
function IntToHandle takes integer i returns handle
return i
return null
endfunction
//=============================================================================================
function LocalVars takes nothing returns gamecache
return InitGameCache("jasslocalvars.w3v")
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
if value==null then
call FlushStoredInteger(LocalVars(),I2S(HandleToInt(subject)),name)
else
call StoreInteger(LocalVars(), I2S(HandleToInt(subject)), name, HandleToInt(value))
endif
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(HandleToInt(subject)),name)
else
call StoreInteger(LocalVars(), I2S(HandleToInt(subject)), name, value)
endif
endfunction
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(HandleToInt(subject)), name)
else
call StoreReal(LocalVars(), I2S(HandleToInt(subject)), name, value)
endif
endfunction
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(HandleToInt(subject)), name)
return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(HandleToInt(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(HandleToInt(subject)), name)
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(HandleToInt(subject)) )
endfunction
//**END**
//##Start##
//===================================================================================================
function SimError takes player ForPlayer, string msg returns nothing
local sound error=CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
if (GetLocalPlayer() == ForPlayer) then
call ClearTextMessages()
call DisplayTimedTextToPlayer( ForPlayer, 0.52, -1.00, 2.00, "|cffffcc00"+msg+"|r" )
call StartSound( error )
endif
call KillSoundWhenDone( error)
set error=null
endfunction
//##end##
Name | Type | is_array | initial_value |
AccurateASLocation | location | No | |
AffectedPlayers | force | No | |
AffectedUnits | group | No | |
Altar | boolean | No | |
Angle | real | No | |
ArcaneSanctum | boolean | No | |
ArcaneVault | boolean | No | |
barrack | boolean | No | |
BH_Black_Hole | unit | No | |
BH_Black_Holes | group | No | |
BH_Valid_Target_Buildings | group | No | |
BH_Valid_Target_Units | group | No | |
Blacksmith | boolean | No | |
BoL_Caster | unit | Yes | |
BoL_Group | group | Yes | |
BoL_TargetGroup | group | Yes | |
CannonTower | boolean | No | |
caster | unit | No | |
Caster | unit | No | |
casters | group | No | |
castervars | real | Yes | |
ConfusionOriginalOwner | player | No | |
ConfusionTarget | unit | No | |
cscache | gamecache | No | |
currentabi | integer | No | |
currentcaster | unit | No | |
currenthurter | unit | No | |
delayhack | real | No | |
dusteffecttimer | timer | No | |
dwarf | unit | No | |
Effect | effect | Yes | |
Effects | effect | No | |
effects2 | effect | No | |
Explosin_Ang | real | No | |
farm | boolean | No | |
freshairtimer | timer | No | |
grannor | unit | No | |
group1 | unit | Yes | |
GroupVar | group | No | |
GryphonAviary | boolean | No | |
hall | boolean | No | |
heist_chance | integer | No | |
heist_fx_integer | integer | No | |
heist_text | texttag | Yes | |
heisteffect | effect | Yes | |
IntegerVar | integer | No | |
JumpDirection | real | No | |
Jumper | unit | No | |
JumperLandingLoc | location | No | |
JumperLoc | location | No | |
JumpInjurDmg | real | No | |
JumpK | real | No | |
JumpRotate | real | No | |
JumpTheta | real | No | |
JumpX | real | No | |
JumpY | real | No | |
Keep | boolean | No | |
L1 | lightning | No | |
L2 | lightning | No | |
L3 | lightning | No | |
L4 | lightning | No | |
light1 | lightning | No | |
light2 | lightning | No | |
light3 | lightning | No | |
light4 | lightning | No | |
lightingorb | unit | No | |
lightningorb_true | boolean | No | |
loghtningorb_explosion | effect | No | |
LosingPlayer | player | No | |
lumbermill | boolean | No | |
ManaBolts | real | Yes | |
ManaStop | boolean | Yes | |
ManaUnit | unit | Yes | |
NovaRotationTargetVar | real | No | |
Odinssnow | abilcode | No | |
Offset | real | No | |
PD_Caster | unit | No | |
PD_Caster_Group | group | No | |
PD_Invading_Enemies | group | No | |
point | location | No | |
PointVar | location | No | |
PointVar2 | location | No | |
Portal_1 | unit | Yes | |
Portal_2 | unit | Yes | |
Portal_Times_Cast | integer | No | |
Portal_Times_Cast_Dummy | integer | No | |
PositionofCasting | location | No | |
RandomComputer | integer | No | |
RandomRace | integer | No | |
RealVar | real | No | |
RealVar2 | real | No | |
ringstop | real | No | |
Rolling_Ang | real | Yes | |
Rolling_Group | group | No | |
Rolling_Number | integer | No | |
Seduce_Target | unit | No | |
Seduce_Targeted_Units | group | No | |
Seize_Casters | unit | Yes | |
Seize_Target | unit | No | |
Seize_Target_Units | group | No | |
Seize_Targets | unit | Yes | |
Seize_Times_Cast | integer | No | |
sourcehack | location | No | |
Special_Point | location | No | |
stalagmitecasters | unit | Yes | |
Stalker | unit | No | |
Sustain_Aura_Caster | unit | No | |
Sustain_Aura_Target_Units | group | Yes | |
Targetnuke | unit | No | |
targetpoint | rect | No | |
TeleEffect | effect | No | |
thorshammerpunktpunkt | location | No | |
timer | timer | No | |
Titan_Group | group | No | |
TitanMissile | boolean | No | |
tower | boolean | No | |
Townhall | boolean | No | |
travellingdust | unit | No | |
TriggeringUnitPointVar | location | No | |
underground | boolean | No | |
Units1 | unit | No | |
UnitVar | unit | No | |
Unwalkable | destructable | Yes | |
Void_RisingEffect | unit | Yes | |
Void_Units | group | Yes | |
Workshop | boolean | No | |
Wormhole | unit | No | |
Wormhole_Effect | effect | No | |
Wormhole_Target_Unit | unit | No | |
Wormhole_Target_Unit_Dummy | unit | No | |
Wormhole_Untargetable_Units | group | No | |
Wormholes | group | No | |
zwergie | unit | No |
//***************************************************************************************************
//*
//* Artic Fury
//* ¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* - The Artic Fury Ability
//* - This Trigger (make sure it points to the right rawcode)
//* Art:
//* - The Ability's target art is the frozen effect
//* - The Ability's Special art spawns if a frozen unit dies.
//* - The Ability's effect art is the start of the spell.
//*
//***************************************************************************************************
//====================================================================================================
// Artic Fury Spell Configuration
//
constant function ArticFury_SpellId takes nothing returns integer
return 'A00E' //// Artic Fury ability Rawcode
endfunction
constant function ArticFury_Area takes real level returns real
return 350+100*level //// the Area of effect formula
endfunction
constant function ArticFury_Duration takes real level returns real
return 20+10*level //// The duration formula
endfunction
constant function ArticFury_FreezingTime takes nothing returns real
return 1.0 //// The time the snow lasts, and before the units get completelly frozen (aesthetic option only)
endfunction
//====================================================================================================
function Trig_ArticFury_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ArticFury_SpellId()
endfunction
function ArticFury_Control takes nothing returns nothing
local unit p=bj_lastCreatedUnit
local effect fx=bj_lastCreatedEffect
local timer t=bj_lastStartedTimer
local boolean b=true
loop
exitwhen IsUnitDeadBJ(p) or TimerGetRemaining(t)<=0
if b and TimerGetElapsed(t)>=ArticFury_FreezingTime() then
set b=false
call SetUnitTimeScale(p,0)
endif
if not IsUnitPaused(p) then
call PauseUnit(p,true)
if not(b) then
call SetUnitTimeScale(p,0)
endif
endif
call TriggerSleepAction(0)
endloop
call DestroyEffect(fx)
if IsUnitAliveBJ(p) then
call PauseUnit(p,false)
call SetUnitTimeScale(p,1)
else
call DestroyEffect( AddSpellEffectById(ArticFury_SpellId(),EFFECT_TYPE_SPECIAL,GetUnitX(p),GetUnitY(p) ) )
call ShowUnit(p,false)
if not IsUnitType(p,UNIT_TYPE_HERO) then
call TriggerSleepAction(0)
call RemoveUnit(p)
endif
endif
endfunction
function ArticFury_DestroyTimer takes nothing returns nothing
call DestroyTimer( GetExpiredTimer() )
endfunction
function Trig_ArticFury_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local location loc=GetSpellTargetLoc()
local group range=CreateGroup()
local unit p
local trigger sp=CreateTrigger()
local timer cronos=CreateTimer()
local rect fxr=RectFromCenterSizeBJ(loc,ArticFury_Area(l)*2,ArticFury_Area(l)*2)
local weathereffect fx=AddWeatherEffect(fxr,'SNbs')
local real d
local real a
call EnableWeatherEffect(fx,true)
call TriggerAddAction(sp,function ArticFury_Control)
call TimerStart(cronos,ArticFury_Duration(l), false,function ArticFury_DestroyTimer)
call GroupEnumUnitsInRangeOfLoc(range,loc,ArticFury_Area(l),null)
set bj_lastStartedTimer=cronos
loop
set p=FirstOfGroup(range)
exitwhen p==null
if IsUnitEnemy(p,GetOwningPlayer(u)) and IsUnitAliveBJ(p) then
call PauseUnit(p,true)
set d=GetRandomReal(0,ArticFury_Area(l))
set a=GetRandomReal(0,360)
call DestroyEffect(AddSpellEffectById(s,EFFECT_TYPE_EFFECT,GetLocationX(loc)+d*CosBJ(a) , GetLocationY(loc)+d*SinBJ(a) ) )
set bj_lastCreatedEffect = AddSpellEffectTargetById(s,EFFECT_TYPE_TARGET,p,"origin")
set bj_lastCreatedUnit=p
call TriggerExecute(sp)
endif
call GroupRemoveUnit(range,p)
endloop
call PolledWait(ArticFury_FreezingTime())
call SetRect(fxr, GetLocationX(loc)-20,GetLocationY(loc)-20,GetLocationX(loc)+20,GetLocationY(loc)+20)
call TriggerSleepAction(0)
call RemoveWeatherEffect(fx)
call RemoveRect(fxr)
call ResetTrigger(sp)
call DestroyTrigger(sp)
call DestroyGroup(range)
call RemoveLocation(loc)
set fx=null
set fxr=null
set u=null
set loc=null
set range=null
set p=null
set sp=null
set cronos=null
endfunction
//=================================================================================================
function InitTrig_Artic_Fury takes nothing returns nothing
set gg_trg_Artic_Fury = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Artic_Fury, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Artic_Fury, Condition( function Trig_ArticFury_Conditions ) )
call TriggerAddAction( gg_trg_Artic_Fury, function Trig_ArticFury_Actions )
endfunction
//*******************************************************************************
//* by n\/Cl34r *
//* *
//* Powerbash *
//* *
//* needs: *
//* - The Handle Variables *
//* - This Trigger *
//* - The 'Powerbash' Spell *
//* *
//* You can easily make this spell work on your map by changing the spell's *
//* Rawcode (The A001 Thing below) to your map's spell rawcode. If you don't *
//* know how to display Rawcodes: Open up the 'Abilities' Tab in your *
//* 'Objects' Module and select 'Display Values as Raw Data' under 'View'. *
//* Now, you should see your map's Rawcodes infront of the spell names. You *
//* can also change other values like damage and bash lenght below. The Art *
//* can be easily changed to fit your needs by changing your spell's 'Special'*
//* (Defines Ground effects under the bashed unit like dust or flames) Art *
//* fields. *
//* *
//*******************************************************************************
//===============================================================================
constant function Powerbash_SpellId takes nothing returns integer
return 'A01M' // Powerbash rawcode
endfunction
constant function Powerbash_Initialdamage takes real level returns real
return 0 + level * 50 // Initial damage a unit suffers when bashed
endfunction
constant function Powerbash_Movement takes real level returns real
return 1 + level * 1 // The distance per 0.01 seconds the target unit moves when bashed
endfunction
constant function Powerbash_Time takes real level returns real
return 2 + level * 0 // How long a unit is bashed and moving
endfunction
constant function Powerbash_Braketime takes real level returns real
return 1 + level * 0 // How long a unit is getting slower until total stop
endfunction
constant function Powerbash_Brakedegree takes real level returns real
return 0.98 // This is the value with that the movement gets multiplied 100 times a second to get
endfunction // a smooth-brake effect. If you use bigger Brake Times, you should also set this
// higher, like 9.85 or 9.955
constant function Powerbash_Movementdamage takes real level returns real
return 0 + level * 0 // The damage a target suffers each move, not used yet
endfunction
constant function Powerbash_Treedamage takes real level returns real
return 5 + level * 5 // The damage a target suffers when crashing through a tree
endfunction
//===============================================================================
function Trig_Powerbash_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == Powerbash_SpellId() ) ) then
return false
endif
return true
endfunction
function Powerbash_GetUnit takes timer t returns unit
return GetHandleHandle(t,"target")
endfunction
function Powerbash_GetUnit2 takes timer t returns unit
return GetHandleHandle(t,"caster")
endfunction
function Powerbash_GetAngle takes timer t returns real
return GetHandleReal(t,"angle")
endfunction
function TreeCheck takes nothing returns boolean
return ( IsDestructableAliveBJ(GetEnumDestructable()) == true )
endfunction
function CountDestructablesInRect_Enum takes nothing returns nothing
if ( TreeCheck() ) then
set bj_randomSubGroupWant = bj_randomSubGroupWant + 1
else
call DoNothing( )
endif
endfunction
function CountDestructablesInCircle takes location where, real radius returns integer
local integer old = bj_randomSubGroupWant
local integer new
set bj_randomSubGroupWant = 0
call EnumDestructablesInCircleBJ(radius, where, function CountDestructablesInRect_Enum)
set new = bj_randomSubGroupWant
set bj_randomSubGroupWant = old
return new
endfunction
function Tree_Killer takes nothing returns nothing
call KillDestructable( GetEnumDestructable() )
endfunction
function Move_Speed takes unit handletarget returns real
return GetHandleReal(handletarget, "movement")
endfunction
function Powerbash_Move takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit target = Powerbash_GetUnit(t)
local unit caster = Powerbash_GetUnit2(t)
local unit handletarget = Powerbash_GetUnit(t)
local real angle = Powerbash_GetAngle(t)
local integer level = GetHandleInt(t,"level")
local real movement = Move_Speed(handletarget)
local location targetloc = GetUnitLoc(target)
local location nextmove = PolarProjectionBJ(targetloc, movement, angle)
local integer trees = 0
local integer brake = GetHandleInt(t,"brake")
if brake==1 then
set movement = Move_Speed(handletarget)
set movement = movement * Powerbash_Brakedegree(level)
call SetHandleReal(handletarget,"movement",movement)
endif
set trees = CountDestructablesInCircle(targetloc, 150)
call UnitDamageTargetBJ( caster, target, ( I2R(trees) * Powerbash_Treedamage(level) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call EnumDestructablesInCircleBJ( 150.00, targetloc, function Tree_Killer )
call UnitDamageTargetBJ( caster, target, Powerbash_Movementdamage(level), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call DestroyEffect(AddSpellEffectByIdLoc(Powerbash_SpellId(), EFFECT_TYPE_SPECIAL, targetloc) )
set nextmove = PolarProjectionBJ(targetloc, movement, angle)
call RemoveLocation(targetloc)
call SetUnitPositionLoc( target, nextmove )
call RemoveLocation(nextmove)
set t = null
set target = null
set targetloc = null
set nextmove = null
set caster = null
set handletarget = null
set trees = 0
endfunction
function Trig_Powerbash_Actions takes nothing returns nothing
local unit target = GetSpellTargetUnit()
local unit caster = GetTriggerUnit()
local unit handletarget = GetSpellTargetUnit()
local location a = GetUnitLoc(caster)
local location b = GetUnitLoc(target)
local real angle = AngleBetweenPoints(a, b)
local timer t = CreateTimer()
local integer level = GetUnitAbilityLevel(caster, GetSpellAbilityId() )
local real movement = Powerbash_Movement(level)
local integer brake = 0
call RemoveLocation(b)
call SetHandleHandle(t,"target",target)
call SetHandleHandle(t,"caster",caster)
call SetHandleReal(t,"angle", angle)
call SetHandleInt(t,"level",level)
call SetHandleReal(t,"movement",level)
call SetHandleReal(handletarget,"movement",movement)
call PauseUnitBJ( true, target )
call UnitDamageTargetBJ( caster, target, Powerbash_Initialdamage(level), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN )
call TimerStart(t, 0.01, true, function Powerbash_Move)
call PolledWait(Powerbash_Time(level))
set brake = 1
call SetHandleInt(t,"brake",brake)
call PolledWait(Powerbash_Braketime(level))
call PauseUnitBJ( false, target )
call FlushHandleLocals(t)
call FlushHandleLocals(handletarget)
call DestroyTimer(t)
call IssuePointOrderLoc( target, "patrol", a ) // This is good for creeps or AOS
call RemoveLocation(a) // Spawnies. It makes "forgotten"
set target = null // Units behind trees impossible.
set caster = null
set a = null
set b = null
set t = null
set handletarget = null
endfunction
//===========================================================================
function InitTrig_Powerbash takes nothing returns nothing
set gg_trg_Powerbash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Powerbash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Powerbash, Condition( function Trig_Powerbash_Conditions ) )
call TriggerAddAction( gg_trg_Powerbash, function Trig_Powerbash_Actions )
endfunction
//*********************************************************************************************
//*
//* Siege of Guthix
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* - The Siege of Guthix Ability.
//* - This Trigger (Make sure it points to the right Rawcode)
//* Notes:
//* - You can change the Ability's Damage, Stun duration and animation with
//* the object editor.
//* - The Ability's Special Art is attached to the weapon of the caster
//*
//*********************************************************************************************
//=============================================================================================
constant function SiegeOfGuthix_SpellId takes nothing returns integer
return 'A01N' //// Rawcode for the Siege Of Guthix Ability
endfunction
//=============================================================================================
function Trig_Siege_of_Guthix_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local unit t=GetSpellTargetUnit()
local real x1=GetUnitX(u)
local real y1=GetUnitY(u)
local real a=Atan2( GetUnitY(t)-y1 , GetUnitX(t)-x1 )
local real x2=GetUnitX(t)+50*Cos(a)
local real y2=GetUnitY(t)+50*Sin(a)
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local effect fx=AddSpellEffectTargetById(s,EFFECT_TYPE_SPECIAL,u,"weapon")
call TriggerSleepAction(0)
call SetUnitPosition(u, x2, y2 )
call DestroyEffect(fx)
set u=null
set t=null
set fx=null
endfunction
function Trig_Siege_of_Guthix_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SiegeOfGuthix_SpellId()
endfunction
//===========================================================================
function InitTrig_Siege_of_Guthix takes nothing returns nothing
set gg_trg_Siege_of_Guthix = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Siege_of_Guthix, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Siege_of_Guthix, Condition( function Trig_Siege_of_Guthix_Conditions ) )
call TriggerAddAction( gg_trg_Siege_of_Guthix, function Trig_Siege_of_Guthix_Actions )
endfunction
//*************************************************************************************************
//*
//* Titillating Delusions
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* - The Caster System 9.0 (http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - The Titillating Delusions Ability
//* - The Handle Variables Functions (see the how to implement category)
//* - This Trigger (make sure it points to the right rawcode)
//* Art:
//* - The Ability's Special art determines the attracting ward model
//* - The Ability's Target art keeps geting spawned at the position of the attackting ward
//* - The Ability's Area Effect Art spawns when the ward vanishes.
//*
//*************************************************************************************************
//=================================================================================================
// Titillating Delusions Spell Configuration:
//
constant function TitillatingDelusions_SpellId takes nothing returns integer
return 'A02F' //// Titillating Delusions Ability Rawcode
endfunction
constant function TDelusions_MaxDuration takes real level returns real
return 10+level*2.0 //// The maximum duration of the attractive ward
endfunction
constant function TDelusions_Area takes real level returns real
return 800+125*level //// The area of effect formula
endfunction
constant function TDelusions_VanishArea takes real level returns real
return 50+level*0.0 //// How close an enemy must be to the ward before cancelling the effect
endfunction
//=================================================================================================
function Trig_Titillating_Delusions_Conditions takes nothing returns boolean
return GetSpellAbilityId() == TitillatingDelusions_SpellId()
endfunction
function Tdelusions_GetUnit takes handle h, string s returns unit
return GetHandleHandle(h,s)
endfunction
function Tdelusions_GetTrigger takes unit u returns trigger
return GetHandleHandle(u,"Tdelusions_Trigger")
endfunction
function Tdelusions_ReOrder takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit c=Tdelusions_GetUnit(t,"c")
call IssuePointOrder(Tdelusions_GetUnit(t,"u"),"move",GetUnitX(c),GetUnitY(c) )
call FlushHandleLocals(t)
call DestroyTimer(t)
set t=null
set c=null
endfunction
function Tdelusions_Order takes nothing returns nothing
local unit u=GetTriggerUnit()
local unit c=Tdelusions_GetUnit(GetTriggeringTrigger(),"c")
local timer t
if GetIssuedOrderId()!=OrderId("move") or GetOrderPointX()!=GetUnitX(c) or GetOrderPointY()!=GetUnitY(c) then
set t=CreateTimer()
call SetHandleHandle(t,"u",u)
call SetHandleHandle(t,"c",c)
call TimerStart(t,0,false,function Tdelusions_ReOrder)
endif
set u=null
set c=null
endfunction
function Tdelusions_inrange takes nothing returns nothing
local unit u=GetTriggerUnit()
local unit t=Tdelusions_GetUnit(GetTriggeringTrigger(),"c")
local trigger trg=CreateTrigger()
if IsUnitEnemy(u,GetOwningPlayer(t)) then
call DestroyTrigger( Tdelusions_GetTrigger(u) )
call SetHandleHandle(u,"Tdelusions_Trigger",trg)
call TriggerAddAction(trg, function Tdelusions_Order )
call SetHandleHandle(trg,"c",t)
call TriggerRegisterUnitEvent(trg,u,EVENT_UNIT_ISSUED_ORDER)
call TriggerRegisterUnitEvent(trg,u,EVENT_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterUnitEvent(trg,u,EVENT_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterUnitEvent(trg,u,EVENT_UNIT_ACQUIRED_TARGET)
call IssuePointOrder(u,"move",GetUnitX(t),GetUnitY(t) )
loop
exitwhen GetHandleInt(GetTriggeringTrigger(),"active")==0
if GetUnitCurrentOrder(u)!=OrderId("move") then
call IssuePointOrder(u,"move",GetUnitX(t),GetUnitY(t) )
endif
call TriggerSleepAction(0)
endloop
call PauseUnit(u,true)
call IssueImmediateOrder(u,"stop")
call PauseUnit(u,false)
call SetHandleHandle(u,"Tdelusions_Trigger",null)
call DestroyTrigger(trg)
endif
set t=null
endfunction
function Trig_Titillating_Delusions_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local location loc=GetSpellTargetLoc()
local unit caster=GetACaster()
local effect fx
local trigger range=CreateTrigger()
local timer t=CreateTimer()
local group g=CreateGroup()
local unit enum
call TimerStart(t,TDelusions_MaxDuration(l),false,null)
call SetUnitPositionLoc(caster,loc)
set fx=AddSpellEffectTargetById(s,EFFECT_TYPE_SPECIAL,caster,"origin")
call SetUnitOwner(caster,GetOwningPlayer(u) ,true)
call TriggerAddAction(range, function Tdelusions_inrange)
call SetHandleHandle(range,"c",caster)
call SetHandleInt(range,"active",1)
call TriggerRegisterUnitInRange(range, caster, TDelusions_Area(l) , null)
loop
call GroupEnumUnitsInRangeOfLoc(g,loc,TDelusions_VanishArea(l),null)
loop
set enum=FirstOfGroup(g)
exitwhen enum==null or (IsUnitEnemy(enum,GetOwningPlayer(u)) and IsUnitAliveBJ(enum) )
call GroupRemoveUnit(g,enum)
endloop
exitwhen TimerGetRemaining(t)<=0 or FirstOfGroup(g)!=null
call TriggerSleepAction(0)
call DestroyEffect( AddSpellEffectTargetById(s,EFFECT_TYPE_TARGET,caster,"origin") )
endloop
if TimerGetRemaining(t)>0 then
call SetUnitVertexColor(caster,255,255,255,64)
call TriggerSleepAction(0)
call SetUnitVertexColor(caster,255,255,255,0)
call DestroyEffect(AddSpellEffectById(s,EFFECT_TYPE_AREA_EFFECT,GetUnitX(caster),GetUnitY(caster)) )
endif
call DestroyEffect(fx)
call RecicleCasterAfterCastEx(caster,4,0,false)
call FlushHandleLocals(range)
call DestroyTrigger(range)
call DestroyGroup(g)
call DestroyTimer(t)
call RemoveLocation(loc)
set loc=null
set g=null
set t=null
set enum=null
set u=null
endfunction
//===========================================================================
function InitTrig_Titillating_Delusions takes nothing returns nothing
set gg_trg_Titillating_Delusions = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Titillating_Delusions, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Titillating_Delusions, Condition( function Trig_Titillating_Delusions_Conditions ) )
call TriggerAddAction( gg_trg_Titillating_Delusions, function Trig_Titillating_Delusions_Actions )
endfunction
function GetSiphonGoldCache takes nothing returns gamecache
return gg_trg_Siphon_Gold
return null
endfunction
function Initialize_SiphonGold_Variables takes nothing returns nothing
local gamecache g = GetSiphonGoldCache()
local integer array gold
local integer SiphonGoldAbility = 'A02G'
set gold[1] = 30 // Level 1 this value is per second
set gold[2] = 50 // Level 2 this value is per second
set gold[3] = 70 // Level 3 this value is per second
call StoreIntegerBJ( SiphonGoldAbility, "Ability", "Ability", g )
call StoreIntegerBJ( gold[1], "Level1", "Gold", g )
call StoreIntegerBJ( gold[2], "Level2", "Gold", g )
call StoreIntegerBJ( gold[3], "Level3", "Gold", g )
endfunction
function SiphonGoldAbility takes nothing returns integer
return GetStoredInteger(GetSiphonGoldCache(), "Ability", "Ability")
endfunction
function SiphonGoldGameCache2Trigger takes gamecache g returns trigger
return g
return null
endfunction
function SiphonGoldHandle2Integer takes handle h returns integer
return h
return 0
endfunction
function SiphonGoldInteger2Effect takes integer i returns effect
return i
return null
endfunction
function SiphonGoldInteger2Unit takes integer i returns unit
return i
return null
endfunction
function SiphonGoldInteger2Timer takes integer i returns timer
return i
return null
endfunction
function SiphonGoldInteger2Trigger takes integer i returns trigger
return i
return null
endfunction
function SiphonGoldInteger2TextTag takes integer i returns texttag
return i
return null
endfunction
function Trig_Siphon_Gold_Floating takes nothing returns nothing
local gamecache g = GetSiphonGoldCache()
local texttag text1 = SiphonGoldInteger2TextTag( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "text1") )
local texttag text2 = SiphonGoldInteger2TextTag( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "text2") )
local integer transp = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "transp")
if (transp < 100) then
set transp = transp + 5
call SetTextTagColorBJ( text1, 100, 100, 0.00, transp )
call SetTextTagColorBJ( text2, 100, 100, 0.00, transp )
call StoreIntegerBJ( transp, "transp", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
else
call DestroyTextTag(text1)
call DestroyTextTag(text2)
call DestroyTimer(GetExpiredTimer())
call DestroyTrigger(GetTriggeringTrigger())
endif
endfunction
function Trig_Siphon_Gold_Timer takes nothing returns nothing
local gamecache g = GetSiphonGoldCache()
local unit caster = SiphonGoldInteger2Unit( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "caster") )
local unit target = SiphonGoldInteger2Unit( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "target") )
local integer max = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "max")
local integer floating = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), "counter")
local integer on = GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "on")
local integer floatgold = 0
local trigger t
local timer c
if (on == 0) then
if (floating > 1) then
set floatgold = floating*2
call StoreIntegerBJ( 0, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
endif
call DestroyEffect( SiphonGoldInteger2Effect( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "Effect1") ) )
call DestroyEffect( SiphonGoldInteger2Effect( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "Effect2") ) )
call DestroyTimer( SiphonGoldInteger2Timer( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "timer") ) )
call DestroyTrigger( SiphonGoldInteger2Trigger( GetStoredInteger(g, I2S(SiphonGoldHandle2Integer(caster)), "trigger") ) )
else
if ( GetPlayerState(GetOwningPlayer(target), PLAYER_STATE_RESOURCE_GOLD) > 1 ) then
call AdjustPlayerStateBJ( 2, GetOwningPlayer(caster), PLAYER_STATE_RESOURCE_GOLD )
call AdjustPlayerStateBJ( -2, GetOwningPlayer(target), PLAYER_STATE_RESOURCE_GOLD )
if (floating == (max/4)) then
set floatgold = max*2/4
set floating = 0
endif
call StoreIntegerBJ( floating + 1, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
elseif (floating > 1) then
set floatgold = (floating-1)*2
call StoreIntegerBJ( 0, "counter", I2S(SiphonGoldHandle2Integer(GetExpiredTimer())), g )
endif
endif
if (floatgold > 0) then
set t = CreateTrigger( )
set c = CreateTimer()
call TriggerRegisterTimerExpireEventBJ( t, c )
call TriggerAddAction( t, function Trig_Siphon_Gold_Floating )
call StartTimerBJ( c, true, 0.07 )
call CreateTextTagUnitBJ( "+" + I2S(floatgold), caster, 0, 10, 100, 100, 100, 0 )
call SetTextTagColorBJ( GetLastCreatedTextTag(), 100, 100, 0.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100, 90 )
call StoreIntegerBJ( SiphonGoldHandle2Integer(GetLastCreatedTextTag()), "text1", I2S(SiphonGoldHandle2Integer(c)), g )
call CreateTextTagUnitBJ( "-" + I2S(floatgold), target, 0, 10, 100, 100, 100, 0 )
call SetTextTagColorBJ( GetLastCreatedTextTag(), 100, 100, 0.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 100, 90 )
call StoreIntegerBJ( SiphonGoldHandle2Integer(GetLastCreatedTextTag()), "text2", I2S(SiphonGoldHandle2Integer(c)), g )
call StoreIntegerBJ( 0, "transp", I2S(SiphonGoldHandle2Integer(c)), g )
endif
endfunction
function Trig_Siphon_Gold_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == SiphonGoldAbility() )
endfunction
function Trig_Siphon_Gold_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local effect e
local gamecache g = GetSiphonGoldCache()
local trigger t = CreateTrigger( )
local timer c = CreateTimer()
local integer level = GetUnitAbilityLevelSwapped(SiphonGoldAbility(), caster)
set e = AddSpecialEffectTarget("war3mapImported\\goldout.mdx",GetSpellTargetUnit(),"origin")
call StoreIntegerBJ( SiphonGoldHandle2Integer(e), "Effect1", I2S(SiphonGoldHandle2Integer(caster)), g )
set e = AddSpecialEffectTarget("war3mapImported\\goldin.mdx",caster,"origin")
call StoreIntegerBJ( SiphonGoldHandle2Integer(e), "Effect2", I2S(SiphonGoldHandle2Integer(caster)), g )
call TriggerRegisterTimerExpireEventBJ( t, c )
call TriggerAddAction( t, function Trig_Siphon_Gold_Timer )
call StoreIntegerBJ( 1, "on", I2S(SiphonGoldHandle2Integer(caster)), g )
call StoreIntegerBJ( SiphonGoldHandle2Integer(c), "timer", I2S(SiphonGoldHandle2Integer(caster)), g )
call StoreIntegerBJ( SiphonGoldHandle2Integer(t), "trigger", I2S(SiphonGoldHandle2Integer(caster)), g )
call StoreIntegerBJ( SiphonGoldHandle2Integer(GetSpellTargetUnit()), "target", I2S(SiphonGoldHandle2Integer(c)), g )
call StoreIntegerBJ( SiphonGoldHandle2Integer(caster), "caster", I2S(SiphonGoldHandle2Integer(c)), g )
call StoreIntegerBJ( 1, "counter", I2S(SiphonGoldHandle2Integer(c)), g )
call StoreIntegerBJ( GetStoredInteger(g, "Gold", "Level" + I2S(level)), "max", I2S(SiphonGoldHandle2Integer(c)), g )
call StartTimerBJ( c, true, (I2R(2) / I2R(GetStoredInteger(g, "Gold", "Level" + I2S(level)) )) )
endfunction
function Trig_Siphon_Gold_End_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local effect e
local gamecache g = GetSiphonGoldCache()
call StoreIntegerBJ( 0, "on", I2S(SiphonGoldHandle2Integer(caster)), g )
endfunction
//===========================================================================
function InitTrig_Siphon_Gold takes nothing returns nothing
local integer i = 0
local trigger t1 = CreateTrigger( )
local trigger t2 = CreateTrigger( )
local trigger g = CreateTrigger( )
set gg_trg_Siphon_Gold = SiphonGoldGameCache2Trigger(InitGameCache( "SiphonGold.w3v" ))
call Initialize_SiphonGold_Variables()
loop
exitwhen i > 11
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
call TriggerRegisterPlayerUnitEventSimple( t1, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterPlayerUnitEventSimple( t2, Player(i), EVENT_PLAYER_UNIT_SPELL_ENDCAST )
endif
set i = i + 1
endloop
call TriggerAddCondition( t1, Condition( function Trig_Siphon_Gold_Conditions ) )
call TriggerAddAction( t1, function Trig_Siphon_Gold_Actions )
call TriggerAddCondition( t2, Condition( function Trig_Siphon_Gold_Conditions ) )
call TriggerAddAction( t2, function Trig_Siphon_Gold_End_Actions )
endfunction
//***************************************************************************************************
//*
//* Nuke
//*
//* Requires:
//* - The Caster System *
//* - The Nuke Ability
//* - This Trigger (Make sure the Configuration section has your map's rawcodes)
//*
//* Optional:
//* - The war3mapimported\Btnnuke.blp icon (give credit to Mc! in that case)
//*
//* Note: To Change the art, use the Object editor an edit these fields of the ability:
//* - Special Art = The missile or whatever you think it is.
//* - Target Art = The explosion (will directly play its death animation)
//*
//***************************************************************************************************
//===================================================================================================
// Nuke Spell Configuration:
//
constant function Nuke_SpellId takes nothing returns integer
return 'A02I' //// The spell id for the nuke ability (its rawcode after copying to your map)
////(Custom Abilities\Neutral hostile\heroes\nuke)
endfunction
constant function Nuke_MainDamageArea takes integer level returns integer
return 450+50*level //// The area for the bigger damage
endfunction
constant function Nuke_HalfDamageArea takes integer level returns integer
return 700+100*level //// The area for the smaller damage
endfunction
constant function Nuke_Damage takes integer level returns integer
return 600+100*level
endfunction
constant function Nuke_Warning takes nothing returns string
return "
Nuclear Launch Detected
"
endfunction
function Nuke_DamageOptions takes real level returns integer
return DamageTypes(ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FORCE)+DamageTrees()
// See the caster system readme for more info
endfunction
//===================================================================================================
function Trig_Nuke_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Nuke_SpellId()
endfunction
function Trig_Nuke_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer l=GetUnitAbilityLevel(u, GetSpellAbilityId() )
local integer a=1
local trigger fin=CreateTrigger()
local trigger stp=CreateTrigger()
local texttag lasser=CreateTextTag()
local location loc=GetSpellTargetLoc()
local unit array m
local effect fx
call DisplayTimedTextToPlayer( GetLocalPlayer(),0,0,60,Nuke_Warning())
call SetTextTagPos( lasser, GetLocationX(loc), GetLocationY(loc), 0)
call SetTextTagColor( lasser, 255,0,0,255)
call SetTextTagText( lasser, ".", 0.075)
call SetTextTagVisibility(lasser,true)
call TriggerRegisterUnitEvent( fin, u, EVENT_UNIT_SPELL_FINISH)
call TriggerRegisterUnitEvent( stp, u, EVENT_UNIT_SPELL_ENDCAST)
loop
exitwhen GetTriggerEvalCount(stp) > 0
call SetTextTagColor( lasser, 255,0,0,0)
call TriggerSleepAction(0)
exitwhen GetTriggerEvalCount(stp) > 0
call SetTextTagColor( lasser, 255,0,0,255)
call TriggerSleepAction(0)
endloop
call DestroyTextTag( lasser )
if GetTriggerEvalCount(fin) > 0 then
set m[0]=GetACaster()
call SetUnitPositionLoc(m[0], loc)
call SetUnitFlyHeight(m[0], 900, 0)
call SetUnitFlyHeight(m[0], 0, 460)
set fx= AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_SPECIAL, m[0], "origin" )
call PolledWait(1.9)
call DestroyEffect(fx)
set udg_delayhack=5
call SetUnitScale( m[0], 0,0,0)
call RecicleCasterAfterCast(m[0],0)
set udg_delayhack=0
set m[0]=GetACaster()
call SetUnitPositionLoc(m[0], loc)
call DestroyEffect( AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_TARGET, m[0], "origin" ) )
call DamageUnitsInAOEExLoc( u, Nuke_Damage(l)/2 ,loc,Nuke_MainDamageArea(l),true,Nuke_DamageOptions(l))
call PolledWait(0.5)
loop
exitwhen a>12
set m[a]=GetACaster()
if a>=11 then
call SetUnitPosition(m[a], GetLocationX(loc), GetLocationY(loc))
else
call SetUnitPosition(m[a], GetLocationX(loc) + 250*CosBJ(a*36), GetLocationY(loc) + 250*SinBJ(a*36))
endif
call SetUnitFlyHeight(m[a], IntegerTertiaryOp( a==12,250,500), 0)
call DestroyEffect( AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_TARGET, m[a], "origin" ) )
set a=a+1
endloop
call DamageUnitsInAOEExLoc( u, Nuke_Damage(l)/2 ,loc,Nuke_HalfDamageArea(l),true,Nuke_DamageOptions(l))
call TriggerSleepAction(10)
loop
set a=a-1
call RecicleCaster(m[a])
set m[a]=null
exitwhen a==0
endloop
endif
set u=null
call DestroyTrigger(fin)
call DestroyTrigger(stp)
call RemoveLocation(loc)
set fin=null
set stp=null
set lasser=null
set loc=null
set fx=null
endfunction
//===========================================================================
function InitTrig_Nuke takes nothing returns nothing
set gg_trg_Nuke = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Nuke, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Nuke, Condition( function Trig_Nuke_Conditions ) )
call TriggerAddAction( gg_trg_Nuke, function Trig_Nuke_Actions )
endfunction
//***************************************************************************************************
//*
//* Cloaking Field
//*
//* Requires:
//* -The Cloaking Field Ability
//* -The Cloaking Field Buff (Make sure the ability uses that buff)
//* -This Trigger (make sure the Configuration Section is pointing to
//* the right abilities/buff Rawcodes)
//*
//* Art:
//* - The Ability's Caster Art randomly appears at the position of the caster during cloak.
//* - The Ability's Special Art appears at the position of the caster at the end of cloak
//* - Other stuff can be changed through the buff.
//*
//***************************************************************************************************
//===================================================================================================
// Cloaking Field Spell Configuration:
//
function CloakingField_AbilityId takes nothing returns integer
return 'A02H' //// The Rawcode for the Cloaking Field Ability in your map
endfunction
function CloakingField_BuffId takes nothing returns integer
return 'B006' //// The Rawcode for the Cloaking Field Buff in your map
endfunction
//===================================================================================================
function Trig_Cloaking_Field_Start_Conditions takes nothing returns boolean
return GetSpellAbilityId() == CloakingField_AbilityId()
endfunction
function Trig_Cloaking_Field_Start_Actions takes nothing returns nothing
local unit caster=GetTriggerUnit()
local integer a=0
call UnitAddAbility( caster, 'Apiv')
call UnitAddAbility( caster, 'Agho')
loop
exitwhen UnitHasBuffBJ(GetTriggerUnit(), CloakingField_BuffId())
call TriggerSleepAction( 0 )
endloop
loop
exitwhen not( UnitHasBuffBJ(GetTriggerUnit(), CloakingField_BuffId()) )
call TriggerSleepAction( 0 )
if ModuloInteger(a,10) == 0 then
call DestroyEffect( AddSpellEffectById(GetSpellAbilityId(), EFFECT_TYPE_CASTER, GetUnitX(caster), GetUnitY(caster) ) )
endif
set a=a+1
endloop
call DestroyEffect( AddSpellEffectTargetById(GetSpellAbilityId(),EFFECT_TYPE_SPECIAL,caster,"origin") )
call UnitRemoveAbility( caster,'Apiv')
call UnitRemoveAbility( caster,'Agho')
endfunction
//===================================================================================================
function InitTrig_Cloaking_Field takes nothing returns nothing
set gg_trg_Cloaking_Field = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Cloaking_Field, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Cloaking_Field, Condition( function Trig_Cloaking_Field_Start_Conditions ) )
call TriggerAddAction( gg_trg_Cloaking_Field, function Trig_Cloaking_Field_Start_Actions )
endfunction
//***************************************************************************************************
//*
//* Thunder Shield
//*
//* Requires:
//* -The Thunder Shield Ability
//* -The Caster System
//* -This Trigger (make sure the Configuration Section is pointing
//* to the right abilities rawcodes)
//*
//* Note: The Spell is currently used by an item, but you can convert it into a hero ability
//* and add levels / tooltips without problems.
//*
//* Art:
//* The Ability's Target art determines the effect used.
//*
//***************************************************************************************************
//===================================================================================================
// Thunder Shield Spell Configuration:
//
constant function ThunderShield_AbilityId takes nothing returns integer
return 'A02J' //* ThurderShield Ability Rawcode
endfunction
constant function ThunderShield_Damage takes integer level returns real
return 5.0+ 25.0*level //* ThunderShield's Damage Formula
endfunction
function ThunderShield_DamageOptions takes nothing returns integer
return DamageTypes(ATTACK_TYPE_CHAOS,DAMAGE_TYPE_LIGHTNING)+DamageOnlyTo(UNIT_TYPE_GROUND)
// See the caster system readme for more info
endfunction
//===================================================================================================
function Trig_ThunderShield_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ThunderShield_AbilityId()
endfunction
function Trig_ThunderShield_Actions takes nothing returns nothing
local unit juer=GetTriggerUnit()
local real grad=0
local real x
local real y
local unit u1
local unit u2
local real ouch=ThunderShield_Damage( GetUnitAbilityLevel(juer,ThunderShield_AbilityId()) )
loop
exitwhen (grad>=3600) or (IsUnitDeadBJ(GetTriggerUnit()))
set x=GetUnitX(juer)+75.00*CosBJ(GetUnitFacing(juer) + grad)
set y=GetUnitY(juer)+75.00*SinBJ(GetUnitFacing(juer) + grad)
call DestroyEffect( AddSpellEffectById( GetSpellAbilityId() , EFFECT_TYPE_TARGET,x,y))
call DamageUnitsInAOEEx( juer, ouch, x, y, 50, false,ThunderShield_DamageOptions())
set x=GetUnitX(juer)+75.00*CosBJ(GetUnitFacing(juer) - grad)
set y=GetUnitY(juer)+75.00*SinBJ(GetUnitFacing(juer) - grad)
call DestroyEffect( AddSpellEffectById( GetSpellAbilityId() , EFFECT_TYPE_TARGET,x,y))
call DamageUnitsInAOEEx( juer, ouch, x, y, 150, false,ThunderShield_DamageOptions())
set grad = grad + 30
call TriggerSleepAction( 0 )
endloop
endfunction
//===================================================================================================
function InitTrig_ThunderShield takes nothing returns nothing
set gg_trg_ThunderShield = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ThunderShield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ThunderShield, Condition( function Trig_ThunderShield_Conditions ) )
call TriggerAddAction( gg_trg_ThunderShield, function Trig_ThunderShield_Actions )
endfunction
//***************************************************************************************************
//*
//* Flames Barrel
//*
//* Requires:
//* -The Explosive (barrel) Ability
//* -The Flames (explosive) Ability
//* -The Caster System
//* -This Trigger (make sure the Configuration Section is pointing
//* to the right abilities rawcodes)
//*
//* Note: The Spell is currently used by an item, but you can convert it into a hero ability
//* and add levels / tooltips without problems.
//*
//* Art:
//* - The Ability's Special art determines the main effect
//* - The Ability's Target art is an effect that keeps appearing at the overhead of the effect
//*
//***************************************************************************************************
//===================================================================================================
// Flames Barrel Spell Configuration:
//
constant function FlamesBarrel_SpellId takes nothing returns integer
return 'A02K' //// The Explosive (barrel) ability rawcode
endfunction
constant function FlamesBarrel_Time takes integer level returns integer
return 3 //// The time before explosion
endfunction
constant function FlamesBarrel_FlamesSpellId takes integer level returns integer
return 'A02L'
endfunction
//===================================================================================================
function Trig_Nafta_Explosives_Conditions takes nothing returns boolean
return GetSpellAbilityId() == FlamesBarrel_SpellId()
endfunction
function Trig_Nafta_Explosives_Actions takes nothing returns nothing
local location loc=GetSpellTargetLoc()
local integer l=GetUnitAbilityLevel( GetTriggerUnit(), FlamesBarrel_SpellId() )
local integer a=FlamesBarrel_Time(l)
local integer abil=FlamesBarrel_FlamesSpellId(l)
local unit barrel= AddDamagingEffectLoc( GetOwningPlayer(GetTriggerUnit()) , SpellEffectModelPath( GetSpellAbilityId(), EFFECT_TYPE_SPECIAL), loc, 0 , a, 0, false)
local texttag Float = CreateTextTagUnitBJ( "", barrel, 50, 15.00, 100, 0.00, 0.00, 0.00 )
call SetUnitScale( barrel, 0.75, 0.75, 0.75)
loop
exitwhen a==0
call SetTextTagText(Float,I2S(a),TextTagSize2Height(15))
call DestroyEffect( AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_TARGET, barrel, "overhead"))
call PolledWait( 1.00 )
set a=a-1
endloop
call DestroyTextTag(Float)
set udg_delayhack = 45
call CasterCastAbilityPointLoc( GetOwningPlayer(GetTriggerUnit()) , abil, "flamestrike", loc , false)
call RemoveLocation(loc)
set udg_delayhack = 0
set Float=null
set barrel=null
set loc=null
endfunction
//===================================================================================================
function InitTrig_Flames_Barrel takes nothing returns nothing
set gg_trg_Flames_Barrel = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Flames_Barrel, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Flames_Barrel, Condition( function Trig_Nafta_Explosives_Conditions ) )
call TriggerAddAction( gg_trg_Flames_Barrel, function Trig_Nafta_Explosives_Actions )
endfunction
//***************************************************************************************************
//*
//* Freezing Bolt
//*
//* Requires:
//* - The Caster System *
//* - The Freezing Bolt Ability
//* - This Trigger (Make sure the Configuration section has your map's rawcodes)
//*
//* Note: To Change the art, use the Object editor an edit these fields of the ability:
//* - Special Art = The missile used by the ability.
//* - Target Art = Attached to the target during the freeze time
//* - Effect Art = Appears when the unit dies if it was frozen
//*
//***************************************************************************************************
//===================================================================================================
// Freezing Bolt Spell Configuration:
//
constant function FreezingBolt_SpellId takes nothing returns integer
return 'A02P'
endfunction
constant function FreezingBolt_Duration takes integer level returns integer
return 1+level*3
endfunction
constant function FreezingBolt_Damage takes integer level returns integer
return 25+50*level
endfunction
constant function FreezingBolt_AttackType takes integer level returns attacktype
return ATTACK_TYPE_CHAOS
endfunction
constant function FreezingBolt_DamageType takes integer level returns damagetype
return DAMAGE_TYPE_COLD
endfunction
//===================================================================================================
function Trig_FreezingBolt_Conditions takes nothing returns boolean
return GetSpellAbilityId() == FreezingBolt_SpellId()
endfunction
function FreezingBolt_TargetDies takes nothing returns nothing
local unit d=GetTriggerUnit()
call DestroyEffect( AddSpellEffectById(FreezingBolt_SpellId(),EFFECT_TYPE_EFFECT, GetUnitX(d) , GetUnitY(d) ) )
if not IsUnitType( d, UNIT_TYPE_HERO) then
call RemoveUnit(d)
endif
set d=null
endfunction
function Trig_FreezingBolt_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer l=GetUnitAbilityLevel(u, GetSpellAbilityId() )
local unit target=GetSpellTargetUnit()
local effect fx
local trigger dead=CreateTrigger()
call PauseUnit(u,true)
call PauseUnit(u,false)
call SetUnitAnimation(u, "attack" )
call ProjectileLaunchToUnit( SpellEffectModelPath( GetSpellAbilityId(), EFFECT_TYPE_SPECIAL), 522, 0.15, GetUnitX(u), GetUnitY(u), 60, target, 60 )
if not IsUnitDeadBJ(target) then
call TriggerRegisterUnitEvent( dead, target, EVENT_UNIT_DEATH )
call TriggerAddAction( dead, function FreezingBolt_TargetDies )
set fx= AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_TARGET, target, "origin" )
call UnitDamageTarget( u,target, FreezingBolt_Damage(l),true,false,FreezingBolt_AttackType(l),FreezingBolt_DamageType(l),WEAPON_TYPE_WHOKNOWS)
call TriggerSleepAction(0)
call PauseUnit( target, true)
call SetUnitTimeScale( target, 0)
call PolledWait(FreezingBolt_Duration(l) )
call DestroyTrigger(dead)
call SetUnitTimeScale( target, 1)
call PauseUnit( target, false)
call DestroyEffect(fx)
endif
set u=null
set fx=null
set target=null
call DestroyTrigger(dead)
set dead=null
endfunction
//===========================================================================
function InitTrig_FreezingBolt takes nothing returns nothing
set gg_trg_FreezingBolt = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_FreezingBolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_FreezingBolt, Condition( function Trig_FreezingBolt_Conditions ) )
call TriggerAddAction( gg_trg_FreezingBolt, function Trig_FreezingBolt_Actions )
endfunction
//***************************************************************************************************
//*
//* Cold Slash
//*
//* Requires:
//* - The Caster System *
//* - The Coldslash Ability
//* - This Trigger (Make sure the Configuration section has your map's rawcodes)
//*
//* Note: To Change the art, use the Object editor and edit these fields of the ability:
//* - Caster Art = The Effect to attach to the hands of the hero
//* - Target Art = The hit art that appears on the target
//* - Special Art = Appears below the hero before hiting a new target-
//*
//***************************************************************************************************
//===================================================================================================
// Cold Slash Spell Configuration:
//
constant function Coldslash_SpellId takes nothing returns integer
return 'A02O' //// The spell id for the Coldslash ability (its rawcode after copying to your map)
////(Custom Abilities\orc\heroes\)
endfunction
constant function Coldslash_TotalHits takes integer level returns integer
return 2+level*1 //// The total number of hits formula
endfunction
constant function Coldslash_Area takes integer level returns integer
return 350+level*10 //// The Area of effect formula (the distance for acquiring new targets)
endfunction
constant function Coldslash_MainDamage takes integer level returns integer
return 50+level*50 //// The damage for the first hit
endfunction
constant function Coldslash_DamageFactor takes integer level returns real
return 1.0 //// the damage factor per hit (it is 1.0 at this moment so it always do the same
//// damage, change it to 0.5 if you want the damage halved like chain lightning.
endfunction
constant function ColdSlash_AttackType takes integer level returns attacktype
return ATTACK_TYPE_NORMAL
endfunction
constant function ColdSlash_DamageType takes integer level returns damagetype
return DAMAGE_TYPE_COLD
endfunction
//===================================================================================================
function Trig_Cold_Slash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Coldslash_SpellId()
endfunction
function Trig_Cold_Slash_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer l=GetUnitAbilityLevel( u, GetSpellAbilityId() )
local group targetlog=CreateGroup()
local group inrange=CreateGroup()
local integer i=Coldslash_TotalHits(l)
local unit target=GetSpellTargetUnit()
local unit picked
local unit other=GetSpellTargetUnit()
local real grad=GetUnitX( u)
local real damage=Coldslash_MainDamage(l)
local effect fx1=AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_CASTER, u, "hand left" )
local effect fx2=AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_CASTER, u, "hand right" )
call PauseUnit(u, true)
call SetUnitPathing(u,false)
loop
call GroupAddUnit( targetlog,target)
set grad=Atan2BJ( GetUnitY(target) - GetUnitY(u), GetUnitX(target) - GetUnitX(u) )
call DestroyEffect( AddSpellEffectById( GetSpellAbilityId(), EFFECT_TYPE_SPECIAL, GetUnitX(u), GetUnitY(u) ) )
call SetUnitFacing( u, grad )
call SetUnitAnimation( u, "attack slam")
call PolledWait(0.25)
call SetUnitPosition( u, GetUnitX(target)+100*CosBJ(grad), GetUnitY(target)+100*SinBJ(grad) )
call UnitDamageTarget(u,target, damage, true,false, ColdSlash_AttackType(l), ColdSlash_DamageType(l), WEAPON_TYPE_WHOKNOWS )
call DestroyEffect( AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_TARGET, target, "origin" ) )
call PolledWait(0.25)
set i=i-1
set damage=damage*Coldslash_DamageFactor(l)
exitwhen i==0 or IsUnitDeadBJ(u)
call GroupClear(inrange)
call GroupEnumUnitsInRange(inrange, GetUnitX(target), GetUnitY(target) , Coldslash_Area(l) , null)
set target=null
set other=null
set grad=1000000
loop
set picked=FirstOfGroup(inrange)
exitwhen picked==null
if IsUnitEnemy(picked, GetOwningPlayer(u) ) and IsUnitAliveBJ(picked) then
if not( IsUnitInGroup(picked,targetlog) ) and SquareRoot( Pow(GetUnitX(u)-GetUnitX(picked),2) + Pow(GetUnitY(u)-GetUnitY(picked),2) ) <= grad then
set grad=SquareRoot( Pow(GetUnitX(u)-GetUnitX(picked),2) + Pow(GetUnitY(u)-GetUnitY(picked),2) )
set target=picked
endif
set other=picked
endif
call GroupRemoveUnit(inrange,picked)
endloop
if target==null then
set target=other
endif
exitwhen target==null
endloop
call DestroyEffect( AddSpellEffectTargetById( GetSpellAbilityId(), EFFECT_TYPE_SPECIAL, u, "origin" ) )
call PauseUnit(u,false)
call SetUnitPathing(u,true)
call SetUnitPosition(u, GetUnitX(u), GetUnitY(u) )
call DestroyEffect(fx1)
call DestroyEffect(fx2)
set fx1=null
set fx2=null
set u=null
call DestroyGroup(targetlog)
set targetlog=null
call DestroyGroup(inrange)
set inrange=null
set target=null
set other=null
endfunction
//===================================================================================================
function InitTrig_Cold_Slash takes nothing returns nothing
set gg_trg_Cold_Slash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Cold_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Cold_Slash, Condition( function Trig_Cold_Slash_Conditions ) )
call TriggerAddAction( gg_trg_Cold_Slash, function Trig_Cold_Slash_Actions )
endfunction
//***************************************************************************************************
//*
//* SnowStorm
//*
//* Requires:
//* -The SnowStorm Ability
//* -The SnowStorm Attack Bonus and Armor Bonus Abilities
//* -This Trigger (make sure the Configuration Section is pointing to
//* the right abilities)
//*
//* Art: The only easy to customize art is the one used by the Frost Attack bonus abilities
//*
//***************************************************************************************************
//===================================================================================================
// SnowStorm Spell Configuration:
//
constant function SnowStormAbilityId takes nothing returns integer
return 'A02M' //* SnowStorm's RawCode (It changes betwen maps)
endfunction
constant function SnowStormBonusAbilityId takes integer b returns integer
if b==1 then
return 'A02N' //* SnowStorm's Attack Bonus RawCode (It changes betwen maps)
elseif b==2 then
return 'AId2' //* SnowStorm's Armor Bonus Rawcode (In case you want to change it with another passive skill)
/////// To Add more bonus abilities to the channeling aura, add a new line starting with
////// elseif b==(number of bonus) then
////// return 'xxxx' ///Being xxxx the rawcode of the new bonus ability.
////// Then in the last return put the total number of bonuses.
endif
return 2 //// The total number of bonus abilities.
endfunction
constant function SnowStormRadius takes integer level returns real
return 400.0 + level * 100 //* SnowStorm's Radius formula
endfunction
//===================================================================================================
function Trig_Snowstorm_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SnowStormAbilityId()
endfunction
function Trig_Snowstorm_Actions takes nothing returns nothing
local unit caster=GetTriggerUnit()
local location loc=GetUnitLoc(caster)
local group inrange
local group affected=CreateGroup()
local group aux=CreateGroup()
local trigger end= CreateTrigger()
local unit current
local integer l=GetUnitAbilityLevel( caster, GetSpellAbilityId())
local real range=SnowStormRadius(l)
local rect efa=Rect( GetUnitX(caster) - range/5,GetUnitY(caster) - range/5,GetUnitX(caster) + range/5,GetUnitY(caster) + range/5)
local weathereffect snow
local integer a=0
set snow=AddWeatherEffect(efa, 'SNhs')
call EnableWeatherEffect(snow, true)
call TriggerRegisterUnitEvent( end, caster, EVENT_UNIT_SPELL_ENDCAST )
call TriggerRegisterUnitEvent( end, caster, EVENT_UNIT_DEATH )
call PolledWait(1)
loop
exitwhen GetTriggerEvalCount( end) > 0
set inrange=GetUnitsInRangeOfLocAll(range, loc)
call GroupAddGroup( affected, aux)
loop
set current= FirstOfGroup(aux)
exitwhen current == null
call GroupRemoveUnit( aux, current)
if not IsUnitInGroup( current, inrange) then
call GroupRemoveUnit( affected, current)
set a=SnowStormBonusAbilityId(0)
loop
exitwhen a==0
call UnitRemoveAbility( current,SnowStormBonusAbilityId(a))
set a=a-1
endloop
endif
endloop
loop
set current= FirstOfGroup(inrange)
exitwhen current==null
call GroupRemoveUnit( inrange, current)
if not IsUnitInGroup( current, affected) and GetOwningPlayer(current) == GetOwningPlayer(caster) then
call GroupAddUnit( affected, current)
set a=SnowStormBonusAbilityId(0)
loop
exitwhen a==0
call UnitAddAbility( current,SnowStormBonusAbilityId(a))
call SetUnitAbilityLevel( current,SnowStormBonusAbilityId(a),l)
set a=a-1
endloop
endif
endloop
call DestroyGroup( inrange)
call TriggerSleepAction(0.5)
endloop
loop
set current= FirstOfGroup(affected)
exitwhen current == null
call GroupRemoveUnit( affected, current)
set a=SnowStormBonusAbilityId(0)
loop
exitwhen a==0
call UnitRemoveAbility( current,SnowStormBonusAbilityId(a))
set a=a-1
endloop
endloop
set caster=null
call RemoveLocation( loc)
set loc=null
call RemoveRect( efa)
call RemoveWeatherEffect( snow)
set efa=null
set snow=null
call DestroyTrigger( end)
set end=null
call DestroyGroup(inrange)
call DestroyGroup(affected)
call DestroyGroup(aux)
set inrange=null
set affected=null
set aux=null
endfunction
//===================================================================================================
function InitTrig_Snowstorm takes nothing returns nothing
set gg_trg_Snowstorm = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Snowstorm, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_Snowstorm, Condition( function Trig_Snowstorm_Conditions ) )
call TriggerAddAction( gg_trg_Snowstorm, function Trig_Snowstorm_Actions )
endfunction
//***************************************************************************************************
//*
//* Ice Wave
//*
//* Requires:
//* -The Ice Wave Ability
//* -The Caster System *
//* -Ice Wave Damage And Freezing ability ,
//* must have the same number of levels as Ice wave
//* -This Trigger (make sure the Configuration Section is pointing
//* to the right abilities rawcodes)
//*
//* Art: To change the effect art use change the art of the Freezing and damage abilities
//*
//***************************************************************************************************
//===================================================================================================
// Ice Wave Spell Configuration:
//
function IceWave_SpellId takes nothing returns integer
return 'A02Q' //* Ice Wave Ability Rawcode
endfunction
function IceWave_AuxAbility takes nothing returns integer
return 'A02R' //* Freezing and Damage Ability Rawcode
endfunction
function IceWave_WavesPerLevel takes integer level returns integer
return 2 + level*4 //* Number of Ice Strikes per level forumula
endfunction
//===================================================================================================
function Trig_IceWave_Conditions takes nothing returns boolean
return GetSpellAbilityId() == IceWave_SpellId()
endfunction
function Trig_IceWave_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local location loc=GetSpellTargetLoc()
local real facing=Atan2(GetLocationY(loc) - y, GetLocationX(loc) - x) //The angle between the hero and the target by any chance?
local integer a=1
local unit ice=GetACaster()
local integer l=GetUnitAbilityLevel( GetTriggerUnit(), IceWave_SpellId() )
call RemoveLocation(loc)
call SetUnitPosition(ice,x,y)
call SetUnitOwner( ice, GetOwningPlayer(u), false)
call UnitAddAbility( ice, IceWave_AuxAbility())
call SetUnitAbilityLevel( ice, IceWave_AuxAbility(),l)
call UnitRemoveAbility( ice, 'Aloc')
call SetUnitInvulnerable( ice, true)
loop
exitwhen a >= IceWave_WavesPerLevel( l )
call SetUnitPosition( ice, x+a*100*Cos(facing)+GetRandomReal(0, 100 ), y+a*100*Sin(facing)+GetRandomReal(0, 100))
call IssueTargetOrder( ice, "frostnova", ice )
call TriggerSleepAction( 0)
set a=a+1
endloop
call SetUnitInvulnerable( ice, false)
call UnitAddAbility( ice, 'Aloc')
call RecicleCaster(ice)
set u=null
set loc=null
set ice=null
endfunction
//===================================================================================================
function InitTrig_IceWave takes nothing returns nothing
local integer a=0
call PreloadAbility( IceWave_AuxAbility())
set gg_trg_IceWave = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_IceWave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_IceWave, Condition( function Trig_IceWave_Conditions ) )
call TriggerAddAction( gg_trg_IceWave, function Trig_IceWave_Actions )
endfunction
//**************************************************************************************************
//*
//* Charge
//*
//* Requires:
//* -The Charge Ability
//* -The Caster System
//* -This Trigger (make sure the Configuration Section is pointing to
//* the right abilities/units)
//*
//* Art:
//* - The Ability's Caster Art model is attached to the caster during charge.
//*
//**************************************************************************************************
//==================================================================================================
// Charge Spell Configuration:
//
constant function ChargeAbilityId takes nothing returns integer
return 'A02T' //* Charge's Ability RawCode (It changes betwen maps)
endfunction
constant function Charge_PassiveBonus takes nothing returns integer
return 'A02U' //* Charge's Speed Improvement Ability RawCode (It changes betwen maps)
endfunction
constant function Charge_Damage takes real level returns real
return 50+level*25
endfunction
constant function Charge_Area takes real level returns real
return 200+20*level
endfunction
function Charge_DamageOptions takes real level returns integer
return DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FORCE) + DamageException(UNIT_TYPE_STRUCTURE,0)
// See the caster system readme for more info
endfunction
//==================================================================================================
function Trig_Charge_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ChargeAbilityId()
endfunction
function Trig_Charge_Actions takes nothing returns nothing
local location target=GetSpellTargetLoc()
local integer t=0
local trigger end=CreateTrigger()
local unit horseman=GetTriggerUnit()
local location loc=GetUnitLoc(horseman)
local integer l=GetUnitAbilityLevel( horseman, ChargeAbilityId())
local effect shock=AddSpellEffectTargetById(ChargeAbilityId(), EFFECT_TYPE_CASTER,horseman,"origin")
local timer dur=CreateTimer()
local real next=0
local unit da=null
local unit db=null
local integer h=GetTerrainCliffLevelBJ(loc)
call TimerStart( dur, 1000000, false, null)
call UnitRemoveBuffs(horseman, true, true)
call UnitAddAbility(horseman, Charge_PassiveBonus() )
call SetUnitPathing( horseman, false )
call SetUnitAcquireRangeBJ( horseman, 0.01 )
call TriggerRegisterUnitEvent( end, horseman, EVENT_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterUnitEvent( end, horseman, EVENT_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterUnitEvent( end, horseman, EVENT_UNIT_ISSUED_ORDER )
call TriggerRegisterUnitEvent( end, horseman, EVENT_UNIT_DEATH )
loop
if GetTerrainCliffLevel( GetUnitX(horseman), GetUnitY(horseman) ) != h then
call SetUnitPositionLoc( horseman, loc)
endif
call MoveLocation( loc , GetUnitX(horseman), GetUnitY(horseman) )
exitwhen GetTriggerEvalCount(end) > t
exitwhen DistanceBetweenPoints(loc, target) < 50.00
call IssuePointOrderLoc( horseman, "move", target )
set t=t+1
if TimerGetElapsed(dur) >= next then
call DamageUnitsInAOEEx(horseman, Charge_Damage(l), GetUnitX(horseman), GetUnitY(horseman), Charge_Area(l), false, Charge_DamageOptions(l))
call RemoveUnit(db)
set db=da
set da=CreateUnit( Player(15), GetUnitTypeId(horseman), 0,0, GetUnitFacing(horseman))
call UnitAddAbility( da, 'Aloc' )
call SetUnitColor( da, GetPlayerColor( GetOwningPlayer(horseman) ) )
call SetUnitPosition(da, GetUnitX(horseman), GetUnitY(horseman) )
call SetUnitVertexColor(da, 255,255,255,127)
call SetUnitVertexColor(db, 255,255,255,63)
call SetUnitTimeScale( da,0)
set next=next+0.25
endif
call TriggerSleepAction(0)
endloop
call RemoveLocation(loc)
call UnitRemoveAbility(horseman, Charge_PassiveBonus() )
call TriggerSleepAction(0)
call SetUnitPathing( horseman, true )
call SetUnitAcquireRangeBJ( horseman, 500.00 )
call RemoveUnit(db)
call TriggerSleepAction(0)
call RemoveUnit(da)
call DestroyTimer(dur)
call DestroyEffect(shock)
call RemoveLocation(target)
call DestroyTrigger(end)
set shock=null
set target=null
set loc=null
set horseman=null
set end=null
set dur=null
set da=null
set db=null
endfunction
//==================================================================================================
function InitTrig_Charge takes nothing returns nothing
set gg_trg_Charge = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Charge, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Charge, Condition( function Trig_Charge_Conditions ) )
call TriggerAddAction( gg_trg_Charge, function Trig_Charge_Actions )
endfunction
//---------------------------------------------------------------------------------------
function getOmniDrain_Abilcode takes nothing returns integer
return 'A03S' //The ability code for the Omni Drain spell.
endfunction
function getOmniDrain_caster takes nothing returns integer
return 'h018' //The unit code for the dummy caster.
endfunction
function getOmniDrain_buff takes nothing returns integer
return 'B00B' //The buff code for the buff Drain Life (target - no fx).
endfunction
function getOmniDrain_DummyLightningFX_Abilcode takes nothing returns integer
return 'A03T' //The ability code for the dummy Multi Drain (lightning fx) spell
endfunction
function getOmniDrain_DummyCheck_Abilcode takes nothing returns integer
return 'A03U' //The ability code for the dummy Multi Drain (forked check) spell
endfunction
function getOmniDrain_CapTargets takes nothing returns integer
return 2+GetUnitAbilityLevelSwapped(getOmniDrain_Abilcode(), GetTriggerUnit())
//Formula for maximum # of targets per level
endfunction
function GetOmniDrain_dmgReturnFactor takes nothing returns real
return 0.5 //Damage return as a factor of the life drained
endfunction
//---------------------------------------------------------------------------------------
function CastAbility takes integer abil, integer level, string order, unit caster, unit target, location loc, real h returns nothing
call CreateNUnitsAtLoc(1,getOmniDrain_caster(), GetOwningPlayer(caster), loc,bj_UNIT_FACING)
call SetUnitPathing( GetLastCreatedUnit(), false )
call SetUnitPositionLoc( GetLastCreatedUnit(), loc )
if h > 40 then
call SetUnitFlyHeightBJ( GetLastCreatedUnit(), h, 10000.00 )
endif
call UnitAddAbilityBJ( abil, GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped( abil, GetLastCreatedUnit(), level )
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
call IssueTargetOrderBJ( GetLastCreatedUnit(), order, target )
endfunction
function GameCache2Trigger takes gamecache g returns trigger
return g
return null
endfunction
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2T takes integer t returns trigger
return t
return null
endfunction
function I2G takes integer g returns group
return g
return null
endfunction
function Trig_MultiDrain_InitConditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == getOmniDrain_Abilcode() ) ) then
return false
endif
return true
endfunction
function GetMultiDrainGameCache takes nothing returns gamecache
return gg_trg_MultiDrain
return null
endfunction
function Trig_MultiDrain_RemoveCasters takes nothing returns nothing
call RemoveUnit(GetEnumUnit())
endfunction
function Trig_MultiDrain_TargetDmgCondition takes nothing returns boolean
local gamecache g = GetMultiDrainGameCache()
local unit dummy = I2U(GetStoredInteger(g, "dummy", I2S(H2I(GetTriggeringTrigger()))))
return ( GetEventDamageSource() == dummy )
endfunction
function Trig_MultiDrain_TargetDmgActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = I2U(GetStoredInteger(g, "caster", I2S(H2I(GetTriggeringTrigger()))))
call SetUnitLifeBJ( caster, ( GetUnitStateSwap(UNIT_STATE_LIFE, caster) + GetEventDamage()*GetOmniDrain_dmgReturnFactor() ) )
endfunction
function Trig_MultiDrain_DmgEvent_Child takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = GetTriggerUnit()
local trigger t = I2T(GetStoredInteger(g,"t",I2S(H2I(caster))))
local trigger u = CreateTrigger()
local real dmg = GetStoredReal(g,"dmg",I2S(H2I(t)))
local integer spell = GetStoredInteger(g,"spell",I2S(H2I(t)))
local location loc = GetUnitLoc(caster)
local group dummycasters = I2G(GetStoredInteger(g, "dummycasters", I2S(H2I(t))))
local unit target = GetEnumUnit()
local unit dummy
call CreateNUnitsAtLoc(1,getOmniDrain_caster(), GetOwningPlayer(caster), loc,bj_UNIT_FACING)
call UnitAddAbilityBJ( getOmniDrain_DummyLightningFX_Abilcode(), GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped(getOmniDrain_DummyLightningFX_Abilcode(),GetLastCreatedUnit(),GetUnitAbilityLevelSwapped(getOmniDrain_Abilcode(),caster))
call UnitApplyTimedLifeBJ( 10.00, 'BTLF', GetLastCreatedUnit() )
call SetUnitPathing( GetLastCreatedUnit(), false )
call SetUnitPositionLoc( GetLastCreatedUnit(), loc )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "drain", target )
set dummy = GetLastCreatedUnit()
call StoreIntegerBJ( H2I(dummy), I2S(H2I(u)), "dummy", g )
call StoreIntegerBJ( H2I(caster), I2S(H2I(u)), "caster", g )
call GroupAddUnitSimple(dummy,dummycasters)
call TriggerRegisterUnitEvent( u, target, EVENT_UNIT_DAMAGED )
call TriggerAddCondition( u, Condition(function Trig_MultiDrain_TargetDmgCondition) )
call TriggerAddAction( u, function Trig_MultiDrain_TargetDmgActions )
call PolledWait(0.5)
loop
call TriggerSleepAction( 0.1 )
exitwhen UnitHasBuffBJ( dummy, getOmniDrain_buff() ) == false
endloop
call GroupRemoveUnitSimple(dummy,dummycasters)
call FlushStoredInteger(g,"dummy", I2S(H2I(u)))
call FlushStoredInteger(g,"caster", I2S(H2I(u)))
call DestroyTrigger(u)
call RemoveLocation(loc)
set loc = null
endfunction
function Trig_MultiDrain_DmgEvent takes nothing returns nothing
call ExecuteFunc("Trig_MultiDrain_DmgEvent_Child")
endfunction
function Trig_MultiDrain_AddEvent takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local trigger t = I2T(GetStoredInteger(g,"t",I2S(H2I(GetTriggerUnit()))))
call TriggerRegisterUnitEvent( t, GetEnumUnit(), EVENT_UNIT_DAMAGED )
endfunction
function Trig_MultiDrain_AddGroupCondition takes nothing returns boolean
local gamecache g = GetMultiDrainGameCache()
local unit dummycaster = I2U(GetStoredInteger(g, "dummycaster", I2S(H2I(GetTriggeringTrigger()))))
return ( GetEventDamageSource() == dummycaster )
//set g = null
endfunction
function Trig_MultiDrain_AddGroupActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local group targets = I2G(GetStoredInteger(g, "targets", I2S(H2I(GetTriggeringTrigger()))))
call GroupAddUnitSimple(GetTriggerUnit(), targets)
endfunction
function Trig_MultiDrain_InitActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local unit dummycaster
local location loc = GetUnitLoc(caster)
local location targetloc = GetUnitLoc(target)
local group targets = CreateGroup()
local group tempgroup
local group dummycasters = CreateGroup()
local trigger t = CreateTrigger()
local integer spell = GetSpellAbilityId()
local trigger endcast = CreateTrigger()
local boolean isendcast = false
local effect fx = AddSpecialEffectTargetUnitBJ( "chest", caster, "Abilities\\Spells\\Other\\Drain\\DrainCaster.mdl" )
call CastAbility(getOmniDrain_DummyCheck_Abilcode(),1,"forkedlightning",caster,target,loc,0)
set dummycaster = GetLastCreatedUnit()
set targets = GetUnitsInRangeOfLocAll(1500.00, loc)
call StoreIntegerBJ( H2I(t), I2S(H2I(GetTriggerUnit())), "t", g )
call ForGroupBJ( targets, function Trig_MultiDrain_AddEvent )
call GroupClear(targets)
call TriggerAddCondition( t, Condition(function Trig_MultiDrain_AddGroupCondition) )
call TriggerAddAction( t, function Trig_MultiDrain_AddGroupActions )
call TriggerRegisterUnitEvent(endcast, caster, EVENT_UNIT_SPELL_ENDCAST)
call StoreIntegerBJ( H2I(caster), I2S(H2I(t)), "caster", g )
call StoreIntegerBJ( H2I(target), I2S(H2I(t)), "target", g )
call StoreIntegerBJ( H2I(dummycaster), I2S(H2I(t)), "dummycaster", g )
call StoreIntegerBJ( H2I(targets), I2S(H2I(t)), "targets", g )
call StoreIntegerBJ( H2I(dummycasters), I2S(H2I(t)), "dummycasters", g )
call StoreIntegerBJ( spell, I2S(H2I(t)), "spell", g )
call StoreBooleanBJ(isendcast, I2S(H2I(t)), "endcast", g)
call PolledWait(0.4)
call GroupRemoveUnitSimple( target, targets )
set tempgroup = GetRandomSubGroup(getOmniDrain_CapTargets()-1, targets)
call DestroyGroup(targets)
set targets = tempgroup
call GroupAddUnitSimple( target, targets )
call ForGroupBJ( targets, function Trig_MultiDrain_DmgEvent )
loop
call TriggerSleepAction(0.1)
exitwhen GetTriggerEvalCount(endcast)>0 or CountUnitsInGroup(dummycasters) == 0 or GetUnitCurrentOrder(caster) != String2OrderIdBJ("drain")
endloop
call PauseUnitBJ( true, caster )
call PauseUnitBJ( false, caster )
call ForGroupBJ( dummycasters, function Trig_MultiDrain_RemoveCasters )
call RemoveLocation(loc)
call RemoveLocation(targetloc)
call DestroyEffect(fx)
call PolledWait(0.1)
call FlushStoredInteger(g,"caster", I2S(H2I(t)))
call FlushStoredInteger(g,"t", I2S(H2I(caster)))
call FlushStoredInteger(g,"target", I2S(H2I(t)))
call FlushStoredInteger(g,"spell", I2S(H2I(t)))
call FlushStoredInteger(g,"targets", I2S(H2I(t)))
call FlushStoredBoolean(g,"endcast", I2S(H2I(t)))
call FlushStoredInteger(g,"dummycaster", I2S(H2I(t)))
call FlushStoredInteger(g,"dummycasters", I2S(H2I(t)))
call DestroyTrigger(t)
call DestroyTrigger(endcast)
call GroupClear(targets)
call DestroyGroup(targets)
call DestroyGroup(tempgroup)
call DestroyGroup(dummycasters)
set t = null
set endcast = null
set targets = null
set dummycasters = null
set loc = null
endfunction
//===========================================================================
function InitTrig_MultiDrain takes nothing returns nothing
local trigger m = CreateTrigger()
set gg_trg_MultiDrain = GameCache2Trigger(InitGameCache( "MultiDrain.w3v" ))
call TriggerRegisterAnyUnitEventBJ( m, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( m, Condition( function Trig_MultiDrain_InitConditions ) )
call TriggerAddAction( m, function Trig_MultiDrain_InitActions )
endfunction
function Trig_JumpFX_Actions takes nothing returns nothing
local effect JumpFX
call AddSpecialEffectTargetUnitBJ( "origin", udg_Jumper, "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" )
call DestroyEffectBJ(JumpFX)
endfunction
//===========================================================================
function InitTrig_JumpFX takes nothing returns nothing
set gg_trg_JumpFX = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_JumpFX, 0.10 )
call TriggerAddAction( gg_trg_JumpFX, function Trig_JumpFX_Actions )
endfunction
//********************************************************************************************************
//*
//* Channeling Summon
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//*
//* - The Channeling Summon Ability
//* - The Caster System ( http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - This Trigger (MAKE SURE TO change the rawcodes in the trigger to
//* the correct ones of your map)
//* Notes:
//* - The Ability's Area Effect art is the summon start model.
//* - The Ability's Special art is the summon end model.
//*
//********************************************************************************************************
//========================================================================================================
// Channeling Summon Spell Configuration:
//
constant function ChannelingSummon_SpellId takes nothing returns integer
return 'A05Y' //ChannelingSummon's ability Rawcode in your map
endfunction
//--------------------------------------------------------------------------------------------------------
function ChannelingSummon_SummonId takes integer level returns integer
local integer array summonid
set summonid[level]='narg' // Default unit id (for unknown levels, just in case
set summonid[1] ='nwrg' // Unit id for level 1
set summonid[2] ='nwrg' // Unit id for level 2
set summonid[3] ='nwrg' // Unit id for level 3
// * create a new line with a new number for each level you want to add to the spell *
return summonid[level]
endfunction
//--------------------------------------------------------------------------------------------------------
constant function ChannelingSummon_Number takes integer level returns integer
return 2+1*level //Total number of units summoned
endfunction
//==================================================================================================
function Trig_ChannelingSummon_Conditions takes nothing returns boolean
return GetSpellAbilityId() == ChannelingSummon_SpellId()
endfunction
function ChannelingSummon_End takes trigger t, group g returns nothing
local unit m
local integer s=ChannelingSummon_SpellId()
loop
set m=FirstOfGroup(g)
exitwhen m==null
call DestroyEffect(AddSpellEffectById(s,EFFECT_TYPE_SPECIAL,GetUnitX(m),GetUnitY(m)))
call RemoveUnit(m)
call GroupRemoveUnit(g,m)
endloop
call DestroyGroup(g)
call TriggerRemoveAction(t,GetAttachedTriggerAction(t,"ac"))
call CleanAttachedVars(t)
call DestroyTrigger(t)
set m=null
set t=null
set g=null
endfunction
function ChannelingSummon_Control takes nothing returns nothing
local trigger t=GetTriggeringTrigger()
local group g=GetAttachedGroup(t,"g")
if GetTriggerEventId()==EVENT_UNIT_DEATH then
call GroupRemoveUnit(g,GetTriggerUnit())
if FirstOfGroup(g)==null then
call IssueImmediateOrder(GetAttachedUnit(t,"u"),"stop")
endif
else
call ChannelingSummon_End(t,g)
endif
set t=null
set g=null
endfunction
function Trig_ChannelingSummon_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local real f=GetUnitFacing(u)
local real x= GetUnitX(u) + 150*CosBJ(f)
local real y= GetUnitY(u) + 150*SinBJ(f)
local trigger t=CreateTrigger()
local integer n=ChannelingSummon_Number(l)
local unit m
local integer i=ChannelingSummon_SummonId(l)
local group g=CreateGroup()
loop
exitwhen n<=0
set m=CreateUnit( GetOwningPlayer(u), i, x,y,f)
call DestroyEffect(AddSpellEffectTargetById(s,EFFECT_TYPE_AREA_EFFECT,m,"origin") )
call GroupAddUnit(g,m)
call SetUnitAnimation(m,"birth")
call QueueUnitAnimation(m,"stand")
call TriggerRegisterUnitEvent(t,m,EVENT_UNIT_DEATH)
call UnitAddType(m,UNIT_TYPE_SUMMONED)
set n=n-1
endloop
call AttachObject(t,"ac",TriggerAddAction(t,function ChannelingSummon_Control))
call AttachObject(t,"g",g)
call AttachObject(t,"u",u)
call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_SPELL_ENDCAST)
set m=null
set t=null
set u=null
set g=null
endfunction
//===========================================================================
function InitTrig_ChannelingSummon takes nothing returns nothing
set gg_trg_ChannelingSummon=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_ChannelingSummon,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_ChannelingSummon,Condition(function Trig_ChannelingSummon_Conditions))
call TriggerAddAction(gg_trg_ChannelingSummon,function Trig_ChannelingSummon_Actions)
endfunction
//********************************************************************************************************
//*
//* Amplify Damage
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//*
//* - The Amplify Damage Ability
//* - The Amplify Damage Buff
//* - The Caster System ( http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - This Trigger (MAKE SURE TO change the rawcodes in the trigger to
//* the correct ones of your map)
//* Note:
//* - Things like the art, the buff model, the spell's target's allowed, duration and that
//* stuff depends completelly on the object editor 's values.
//*
//********************************************************************************************************
//========================================================================================================
// Amplify Damage Spell Configuration
//
constant function AmplifyDamage_SpellId takes nothing returns integer
return 'A05Z' //Amplify Damage's rawcode in your map
endfunction
//--------------------------------------------------------------------------------------------------------
constant function AmplifyDamage_BuffId takes nothing returns integer
return 'B00H' //Amplify Damage's Buff rawcode in your map
endfunction
//--------------------------------------------------------------------------------------------------------
constant function AmplifyDamage_MissileSpeed takes nothing returns real
return 2000. //Missile speed, should match the one of the ability in the object editor
endfunction
//--------------------------------------------------------------------------------------------------------
constant function AmplifyDamage_Area takes real level returns real
return 200+0*level //Area of effect , this should also match the one of the object editor
endfunction
//--------------------------------------------------------------------------------------------------------
constant function AmplifyDamage_Factor takes real level returns real
return 1+0.5*level //The factor for the damage gotten by the unit, wasn't tested with values lower than 1.0
endfunction
//==================================================================================================
function Trig_AmplifyDamage_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == AmplifyDamage_SpellId())
endfunction
function AmplifyDamage_UnIgnore takes nothing returns nothing
local timer t=GetExpiredTimer()
call AttachBoolean(GetAttachedUnit(t,"u"),"IgnoreAmplifyDamage",false)
call CleanAttachedVars(t)
call DestroyTimer(t)
set t=null
endfunction
function AmplifyDamage_Damage takes nothing returns nothing
local unit u=GetTriggerUnit()
local trigger t=GetTriggeringTrigger()
local group g=GetAttachedGroup(t,"g")
local integer l=GetAttachedInt(t,"l")
local timer c
local real x
if (GetTriggerEventId()==EVENT_UNIT_DEATH) or (GetUnitAbilityLevel(u,AmplifyDamage_BuffId())==0) then
call GroupRemoveUnit(g,u)
endif
set x=GetEventDamage()
if (x>0) and IsUnitInGroup(u,g) and not(GetAttachedBoolean(u,"IgnoreAmplifyDamage")) then
set x=x*(AmplifyDamage_Factor(l)-1)
call SetWidgetLife(u,RMaxBJ(1,GetWidgetLife(u)-x))
// Next is to prevent the factor to stack, causing massive, abusable damage.
call AttachBoolean(u,"IgnoreAmplifyDamage",true)
set c=CreateTimer()
call AttachObject(c,"u",u)
call TimerStart(c,0,false,function AmplifyDamage_UnIgnore)
set c=null
endif
if (FirstOfGroup(g)==null) then
call DestroyGroup(g)
call TriggerRemoveAction(t,GetAttachedTriggerAction(t,"ac"))
call CleanAttachedVars(t)
call DestroyTrigger(t)
endif
set g=null
set u=null
set t=null
endfunction
function Trig_AmplifyDamage_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local unit v=GetSpellTargetUnit()
local group g=CreateGroup()
local group a
local unit p
local real x=GetUnitX(v)
local real y=GetUnitY(v)
local trigger t=null
call PolledWait( SquareRoot(Pow(GetUnitX(u)-x,2)+Pow(GetUnitY(u)-y,2)) / AmplifyDamage_MissileSpeed() )
call TriggerSleepAction(0)
call GroupEnumUnitsInRange(g,x,y,AmplifyDamage_Area(l)+50,null)
loop
set p=FirstOfGroup(g)
exitwhen p==null
call GroupRemoveUnit(g,p)
if (GetUnitAbilityLevel(p,AmplifyDamage_BuffId())>0) then
if t==null then
set t=CreateTrigger()
call AttachObject(t,"ac",TriggerAddAction(t,function AmplifyDamage_Damage))
call AttachInt(t,"l",l)
set a=CreateGroup()
call AttachObject(t,"g",a)
endif
call TriggerRegisterUnitEvent(t,p,EVENT_UNIT_DAMAGED)
call TriggerRegisterUnitEvent(t,p,EVENT_UNIT_DEATH)
call GroupAddUnit(a,p)
endif
endloop
set a=null
set t=null
set p=null
set u=null
set v=null
endfunction
//==================================================================================================
function InitTrig_AmplifyDamage takes nothing returns nothing
set gg_trg_AmplifyDamage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AmplifyDamage, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_AmplifyDamage, Condition( function Trig_AmplifyDamage_Conditions ) )
call TriggerAddAction( gg_trg_AmplifyDamage, function Trig_AmplifyDamage_Actions )
endfunction
//********************************************************************************************************
//*
//* Magma Rage
//* ¯¯¯¯¯¯¯¯¯¯
//* Requires:
//*
//* - The Magma Rage ability
//* - The Caster System ( http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - This Trigger (MAKE SURE TO change the rawcodes in the trigger to
//* the correct ones of your map)
//* Notes:
//* - The Ability's Special art determines the Magma Explosion model
//*
//********************************************************************************************************
//==================================================================================================
// Magma Rage Spell Configuration:
//
constant function MagmaRage_SpellId takes nothing returns integer
return 'A060' //Magma Rage's Rawcode in your map
endfunction
//--------------------------------------------------------------------------------------------------------
constant function MagmaRage_Chance takes real level returns real
return level*8 //Chance of causing the magma explosion
endfunction
//--------------------------------------------------------------------------------------------------------
constant function MagmaRage_Cooldown takes real level returns real
return 18.0-level*2 //Cooldown of the explosion
endfunction
//--------------------------------------------------------------------------------------------------------
constant function MagmaRage_Damage takes real level returns real
return 15+level*15 //Damage of the explosion
endfunction
//--------------------------------------------------------------------------------------------------------
constant function MagmaRage_Area takes real level returns real
return 225+25*level //Area of the explosion
endfunction
//--------------------------------------------------------------------------------------------------------
function MagmaRage_DamageOptions takes integer l returns integer
return DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FIRE)+DamageException(UNIT_TYPE_FLYING,0)
//
// Will do fire spell damage, and won't hurt flying units.
// Other damage options can be used, check the caster system map for more information
//
endfunction
//==================================================================================================
function Trig_MagmaRage_Conditions takes nothing returns boolean
return ( GetLearnedSkill() == MagmaRage_SpellId() )
endfunction
function MagmaRage_Effect takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer l=GetUnitAbilityLevel( u, MagmaRage_SpellId() )
local timer t= GetAttachedTimer(u,"MagmaRageTimer")
if l==0 then
call AttachObject( u, "magmaragetrigger", null)
call AttachObject( u, "MagmaRageTimer", null)
call DestroyTrigger( GetTriggeringTrigger() )
call DestroyTimer( t)
elseif (TimerGetRemaining(t)<=0) and (GetRandomReal(0,100)<=MagmaRage_Chance(l)) then
call TimerStart(t,MagmaRage_Cooldown(l),false,null)
call DestroyEffect( AddSpellEffectTargetById( MagmaRage_SpellId(), EFFECT_TYPE_SPECIAL, u, "origin" ) )
if not IsUnitIllusion(u) then
call DamageUnitsInAOEEx( u , MagmaRage_Damage(l), GetUnitX(u), GetUnitY(u), MagmaRage_Area(l), false,MagmaRage_DamageOptions(l))
endif
endif
set u=null
set t=null
endfunction
function Trig_MagmaRage_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local trigger t
if GetAttachedTrigger(u, "magmaragetrigger" ) == null then
set t=CreateTrigger()
call TriggerAddAction(t, function MagmaRage_Effect )
call TriggerRegisterUnitEvent( t,u, EVENT_UNIT_DAMAGED )
call AttachObject(u, "magmaragetrigger", t)
call AttachObject(u, "MagmaRageTimer", CreateTimer())
set t=null
endif
set u=null
endfunction
function MagmaRage_Enum takes nothing returns nothing
local group g=CreateGroup()
local unit p
local integer s=MagmaRage_SpellId()
local trigger t
call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
loop
set p=FirstOfGroup(g)
exitwhen p==null
call GroupRemoveUnit(g,p)
if GetUnitAbilityLevel(p,s)>0 then
set t=CreateTrigger()
call TriggerAddAction(t, function MagmaRage_Effect )
call TriggerRegisterUnitEvent( t,p, EVENT_UNIT_DAMAGED )
call AttachObject(p, "magmaragetrigger", t)
call AttachObject(p, "MagmaRageTimer", CreateTimer())
set t=null
endif
endloop
call DestroyTimer(GetExpiredTimer())
set p=null
set g=null
endfunction
function InitTrig_MagmaRage takes nothing returns nothing
set gg_trg_MagmaRage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_MagmaRage, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_MagmaRage, Condition( function Trig_MagmaRage_Conditions ) )
call TriggerAddAction( gg_trg_MagmaRage, function Trig_MagmaRage_Actions )
call TimerStart(CreateTimer(),-1,false,function MagmaRage_Enum)
endfunction
//***************************************************************************************************
//*
//* Ice Nova
//* ¯¯¯¯¯¯¯¯
//* Requires:
//* - The Caster System 10.0 or greater
//* http://www.wc3campaigns.com/forumdisplay.php?f=534
//* - The Ice Nova Ability
//* - The Ice Nova Freezing ability (should have as much levels as Ice Nova)
//* - This Trigger (Make sure the Configuration section has your map's rawcodes)
//*
//* Art:
//* - The Ability's Missile Art is The Nova shard effect, and the second Missile value is
//* the shard flying height.
//* - The Ability's Special Art keeps being spawned at the nova shards
//* - The Ability's Target Art represents the frozen effect, the second target value is the
//* attachment point of the frozen effect.
//* - The Ability's Area Effect Art is spawned when a frozen unit dies.
//*
//* Note : The freezing ability shouldn't do damage
//*
//***************************************************************************************************
//===================================================================================================
// Ice Nova Spell Configuration:
//
constant function IceNova_SpellId takes nothing returns integer
return 'A061' // Rawcode of the Ice Nova Ability in your map
endfunction
constant function IceNova_FreezingSpellId takes nothing returns integer
return 'A062' // Rawcode of the Ice Nova Freezing Ability in your map
endfunction
constant function IceNova_Weather takes nothing returns integer
return 'SNhs' //The weather effect, currently it is Northern heavy snow, change it to 0 , for no effect.
endfunction
constant function IceNova_DirInc takes nothing returns integer
return 0 // Angle Increment per period, would make the nova have a spiral personality.
endfunction
constant function IceNova_Delay takes integer level returns real
return 2.5+0*level // How much time to wait before releasing the nova.
endfunction
constant function IceNova_Area takes real level returns real
return 350+level*100 // The maximum distance between the shards and the hero before stopping the effect.
endfunction
constant function IceNova_Number takes integer level returns integer
return 15+level*0 //// The number of Ice nova missiles
endfunction
constant function IceNova_Scale takes integer level returns real
return 2.0+level*0 //// The model scale of Ice nova missiles
endfunction
constant function IceNova_Range takes real level returns real
return 50+0*level // How close an unit must be to a shard to get affected by damage / stacking freezing
endfunction
constant function IceNova_Damage takes real level returns real
return 35+25*level // Damage when a shard comes close to an unit
endfunction
constant function IceNova_FrozenDuration takes real level returns real
return 6+3*level // Duration of the frozen effect
endfunction
constant function IceNova_StackedFrozenDuration takes real level returns real
return level // Increment of the frozen effect per new shard that hits the unit
endfunction
constant function IceNova_AffectAllied takes nothing returns boolean
return true // True in case you want the spell to affect allied units, otherwise false
endfunction
function IceNova_TargetOptions takes integer level returns integer
return DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_COLD) + DontDamageSelf() + DamageOnlyTo(UNIT_TYPE_GROUND) + DamageException(UNIT_TYPE_STRUCTURE,0.5)
// Does Cold (Magical) spell damage, won't affect the hero himself nor non Ground Units,
// And does half damage against buildings.
// See caster system readme for more information.
endfunction
//===================================================================================================
function Trig_Ice_Nova_Conditions takes nothing returns boolean
return GetSpellAbilityId() == IceNova_SpellId()
endfunction
function IceNova_GetU takes trigger t returns unit
return GetHandleHandle(t,"u")
endfunction
function IceNova_dies takes nothing returns nothing
local unit u=GetTriggerUnit()
call DestroyEffect(AddSpellEffectById(IceNova_SpellId(),EFFECT_TYPE_AREA_EFFECT, GetUnitX(u), GetUnitY(u) ))
if IsUnitType(u,UNIT_TYPE_HERO) then
call ShowUnit(u,false)
else
call RemoveUnit(u)
endif
set u=null
endfunction
function IceNova_DoIT takes nothing returns nothing
local unit u=udg_currenthurter
local unit t=GetTriggerUnit()
local integer l=bj_forLoopAIndex
local integer s=IceNova_SpellId()
local timer c=CreateTimer()
local effect fx= AddSpellEffectTargetById(s,EFFECT_TYPE_TARGET,t,GetAbilityEffectById(s,EFFECT_TYPE_TARGET,1))
local real v
local trigger death=CreateTrigger()
local triggeraction ac=TriggerAddAction(death,function IceNova_dies)
call TriggerRegisterUnitEvent(death,t,EVENT_UNIT_DEATH)
call PauseUnit(t,true)
call SetUnitTimeScale(t,0)
call TimerStart(c,IceNova_FrozenDuration(l),false,null)
call SetHandleInt(t,"IceNova_OnIce",1)
loop
if TimerGetRemaining(c)==0 then
set v=GetHandleReal(t,"IceNova_StackIce")
if v>0 then
call SetHandleReal(t,"IceNova_StackIce",0)
call TimerStart(c,v,false,null)
endif
endif
exitwhen TimerGetRemaining(c)==0
call PauseUnit(t,true)
call TriggerSleepAction(0)
endloop
call SetHandleInt(t,"IceNova_OnIce",0)
call TriggerRemoveAction(death,ac)
call DestroyTrigger(death)
set death=null
set ac=null
call PauseUnit(t,false)
call SetUnitTimeScale(t,1)
call DestroyEffect(fx)
call CasterCastAbilityLevel(Player(15),IceNova_FreezingSpellId(),l,"frostnova",t,true)
call DestroyTimer(c)
set fx=null
set c=null
set u=null
set t=null
endfunction
function IceNova_Inrange takes nothing returns nothing
local trigger g=GetTriggeringTrigger()
local unit u=IceNova_GetU(g)
local integer l
local unit t=GetTriggerUnit()
local real fct
if IceNova_AffectAllied() or IsUnitEnemy(t,GetOwningPlayer(u)) then
set l=GetHandleInt(g,"l")
set fct= GetDamageFactorByOptions(u,t,IceNova_TargetOptions(l))
if fct != 0 then
call UnitDamageTarget(u,t,IceNova_Damage(l)*fct,true,false,null,null,null)
if GetHandleInt(t,"IceNova_OnIce")==0 then
set udg_currenthurter=u
set bj_forLoopAIndex=l
call ExecuteFunc("IceNova_DoIT")
else
call SetHandleReal(t,"IceNova_StackIce",GetHandleReal(t,"IceNova_StackIce")+ IceNova_StackedFrozenDuration(l))
endif
endif
endif
set u=null
set t=null
set g=null
endfunction
function Trig_Ice_Nova_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local trigger end=CreateTrigger()
local real a=IceNova_Area(l)*0.5
local rect r=Rect( x - a, y - a, x + a, y + a )
local weathereffect we=AddWeatherEffect(r,IceNova_Weather())
local effect array fx
local unit array m
local integer i=0
local integer n=IceNova_Number(l)
local player P=GetOwningPlayer(u)
local trigger range
local triggeraction ac
local real o=0
local sound sfx=CreateSoundFromLabel(GetAbilitySoundById(s,SOUND_TYPE_EFFECT_LOOPED),true,true,true,0,0)
call EnableWeatherEffect(we,true)
call SetSoundPosition(sfx,x,y,100)
call StartSound(sfx)
call TriggerRegisterUnitEvent(end,u,EVENT_UNIT_SPELL_ENDCAST)
call PolledWait( IceNova_Delay(l))
if GetTriggerEvalCount(end)==0 then
set range=CreateTrigger()
set ac=TriggerAddAction(range,function IceNova_Inrange)
call SetHandleHandle(range,"u",u)
call SetHandleInt(range,"l",l)
set a=IceNova_Scale(l)
loop
exitwhen i>=n
set m[i]=AddCasterFacing(360*(i/n))
call SetUnitPosition(m[i],x,y)
call TriggerRegisterUnitInRange(range,m[i], IceNova_Range(l),null)
call SetUnitFlyHeight(m[i], S2R(GetAbilityEffectById(s,EFFECT_TYPE_MISSILE,1)),0 )
call SetUnitScale(m[i],a,a,a)
set fx[i]= AddSpellEffectTargetById(s,EFFECT_TYPE_MISSILE,m[i],"origin")
call SetUnitOwner(m[i],P,true)
set i=i+1
endloop
loop
exitwhen GetTriggerEvalCount(end)>0
exitwhen not IsUnitInRange(u,m[0],IceNova_Area(l))
set i=0
loop
exitwhen i>=n
set a=(((360*i)/n)+o) * bj_DEGTORAD
set x=GetUnitX(m[i])
set y=GetUnitY(m[i])
call IssuePointOrder(m[i], "move", x+200*Cos(a), y+200*Sin(a) )
call DestroyEffect( AddSpellEffectTargetById(s, EFFECT_TYPE_SPECIAL, m[i],"origin") )
set i=i+1
endloop
call TriggerSleepAction(0)
set o=o+IceNova_DirInc()
endloop
set i=0
loop
exitwhen i>=n
call ExplodeUnitBJ(m[i])
call SetUnitScale(m[i],1,1,1)
call DestroyEffect(fx[i])
set m[i]=null
set fx[i]=null
set i=i+1
endloop
if GetTriggerEvalCount(end)==0 then
call PauseUnit(u,true)
call IssueImmediateOrder(u,"stop")
call PauseUnit(u,false)
endif
call TriggerRemoveAction(range,ac)
set ac=null
call DestroyTrigger(range)
set range=null
endif
call StopSound(sfx,true,true)
set sfx=null
set P=null
call RemoveWeatherEffect(we)
call RemoveRect(r)
set r=null
set we=null
call DestroyTrigger(end)
set end=null
set u=null
endfunction
//===========================================================================0=0=0=0=0=0=0=0=0=0=0=0=
function InitTrig_Ice_Nova takes nothing returns nothing
call PreloadAbility(IceNova_FreezingSpellId())
set gg_trg_Ice_Nova = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Ice_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_Ice_Nova, function Trig_Ice_Nova_Actions )
call TriggerAddCondition( gg_trg_Ice_Nova, Condition(function Trig_Ice_Nova_Conditions ) )
endfunction
//===========================================================================
function InitTrig_Caster_Setup takes nothing returns nothing
call CreateCasters(12)
// Create 12 Initial casters available for any usage of a caster function
// Not a needed step, but might help a little against first cast lag
// Better if you do it , at least with a value of 1 , you can just copy this trigger to your map.
endfunction
//***************************************************************************************************
//*
//* Copy Cat
//*
//* Requires:
//* - The Caster System *
//* - The Handle Variables Functions
//* - This Trigger (Make sure the Configuration section has your map's rawcodes)
//*
//* Note : To Change the art, use the Object editor an edit these fields of the ability:
//* - Caster Art = Attached to the caster during transformation
//* - Target Art = Attached to the target during transformation
//* - Effect Art = Shows at the end of transformation process
//* - Special Art = Shows at the end of the effect of the spell
//*
//* Note II: If you have tomes in your map, get something to avoid units picking them, otherwise
//* The game can crash if the hero takes the form of a unit and then tries to pick
//* an item.
//*
//***************************************************************************************************
//===================================================================================================
// Copy Cat Spell Configuration:
//
constant function CopyCat_SpellId takes nothing returns integer
return 'A065' //// The Your map's Rawcode for the Copy Cat skill.
endfunction
constant function CopyCat_TurnOffSpellId takes nothing returns integer
return 'A066'//// The Your map's Rawcode for the Original Form ability.
endfunction
constant function CopyCat_WaterDetector takes nothing returns integer
return 'Asb2' //// Naga Royal Guard Submerge, used to detect deep water, put 0 here if you don't
//// want the hero to die when it ends in deep water
endfunction
constant function CopyCat_Inventory takes nothing returns integer
return 'AInv' //// The inventory skill used by the hero that is supposed to cast copy cat.
endfunction
constant function CopyCat_MorphDelay takes integer level returns integer
return 2+level*0 /// The transformation process duration, if the caster may die during this time.
endfunction
constant function CopyCat_Duration takes integer level returns integer
return 35+25*level //// The duration of the spell.
endfunction
constant function CopyCat_HeroDurationFactor takes integer level returns real
return 0.5+level*0 //// If the target is a hero, the duration is multiplied by this
endfunction
function CopyCat_RemoveBadInventories takes unit u returns nothing
//// This section is important if your map is going to have those unit types with inventory skills
//// that aren't able to use items, if you have more of these inventory skills in your map, add them
//// To this like copying one of the lines and then replace the 4 letter code for the new line to
//// match the 4 letter code of the inventory skill
call UnitRemoveAbility(u, 'Aihn') //// Unit Inventory (Human)
call UnitRemoveAbility(u, 'Aien') //// Unit Inventory (Night Elf)
call UnitRemoveAbility(u, 'Aion') //// Unit Inventory (Orc)
call UnitRemoveAbility(u, 'Aiun') //// Unit Inventory (Undead)
call UnitRemoveAbility(u, 'Apak') //// Pack Mule
endfunction
//===================================================================================================
function Trig_CopyCat_Conditions takes nothing returns boolean
return GetSpellAbilityId() == CopyCat_SpellId()
endfunction
function CopyCat_IsPointWater takes real x, real y returns boolean
local unit c=CasterCastAbilityPoint(Player(15),CopyCat_WaterDetector(),"submerge",x,y,false)
local boolean b=( GetUnitCurrentOrder(c)==OrderId("submerge") )
if b then
call PauseUnit(c,true)
call IssueImmediateOrder(c,"stop")
call PauseUnit(c,false)
endif
set c=null
return b
endfunction
function CopyCat_GetOriginal takes unit c returns unit
return GetHandleHandle( c, "copycatrealunit")
endfunction
function CopyCat_MimicUnitHP takes unit u, unit c returns nothing
call SetWidgetLife(u, RMaxBJ( GetWidgetLife(c) / GetUnitState(c, UNIT_STATE_MAX_LIFE) * GetUnitState(u, UNIT_STATE_MAX_LIFE) , 1.00 ) )
endfunction
function CopyCat_Restore takes unit c, unit u returns unit
local boolean sel=false
local integer a=0
local real x=GetUnitX(c)
local real y=GetUnitY(c)
local player p=GetOwningPlayer(c)
if u==null then
set u=CopyCat_GetOriginal( c)
endif
call SetUnitOwner(u,p,false)
call SetUnitPathing( c, false)
call SetUnitPosition( u, x, y )
loop
exitwhen a>5
call UnitAddItem( u, UnitItemInSlot(c,a) )
set a=a+1
endloop
set sel = IsUnitSelected( c, GetOwningPlayer(u) )
call SetHandleHandle(c, "copycatrealunit", null)
call RemoveUnit(c)
call ShowUnit( u, true)
call SetUnitPosition( u, x, y )
call DestroyEffect( AddSpellEffectById( CopyCat_SpellId(), EFFECT_TYPE_SPECIAL, x,y ) )
if not IsUnitDeadBJ(c) and CopyCat_WaterDetector()!=0 and CopyCat_IsPointWater(x,y) then
call SetUnitPathing(u,false)
call SetUnitPosition( u, x, y )
call KillUnit(u)
call SetUnitAnimation(u,"death")
else
call SetUnitAnimation( u, "stand")
if sel then
call SelectUnitAddForPlayer( u, GetOwningPlayer(u) )
endif
endif
return u
endfunction
function CopyCat_Controller takes nothing returns nothing
local unit c=GetTriggerUnit()
local unit u=CopyCat_GetOriginal(c)
if GetSpellAbilityId() == CopyCat_TurnOffSpellId() then
call CopyCat_Restore(c,u)
else
call CopyCat_MimicUnitHP(u,c)
call SetUnitManaPercentBJ( u, GetUnitManaPercent(c))
call SetUnitFacing(u , GetUnitFacing(c))
endif
set u=null
set c=null
endfunction
function CopyCat_Dies takes nothing returns nothing
local unit u=CopyCat_Restore(GetTriggerUnit(),null)
if GetKillingUnit() == null then
call KillUnit( u )
else
call DamageUnit( GetOwningPlayer(GetKillingUnit()), GetWidgetLife(u)+3, u)
endif
endfunction
function Trig_CopyCat_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local unit target=GetSpellTargetUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel( u,s )
local unit clone
local gamecache g
local trigger ctrl=CreateTrigger()
local trigger dead=CreateTrigger()
local boolean sel=false
local integer a=0
local timer t=CreateTimer()
local real mana=-1
local effect fx1
local effect fx2
if CopyCat_GetOriginal(u) != null then
set u=CopyCat_Restore( u,null)
endif
if t!=null then
set g=InitGameCache("copycat.c")
call PauseUnit(u,true)
call StoreUnit( g, "copycatclone","byVexorian", target)
set clone= RestoreUnit(g, "copycatclone", "byVexorian", GetOwningPlayer(target), GetUnitX(u), GetUnitY(u), GetUnitFacing(u) )
set a=0
loop
exitwhen a>5
call RemoveItem( UnitItemInSlot(clone,a) )
set a=a+1
endloop
call SetUnitColor( clone, GetPlayerColor(GetOwningPlayer(u)) )
call SetUnitOwner( clone, Player(15), false)
call PauseUnit(clone,true)
call SetUnitPathing(clone,false)
call SetUnitInvulnerable(clone,true)
call SetUnitPosition(clone, GetUnitX(u), GetUnitY(u) )
call FlushGameCache(g)
set g=null
call TimerStart( t, CopyCat_MorphDelay(l), false, null)
call SetUnitVertexColor(clone,255,255,255, 0)
call SetUnitVertexColor( u ,255,255,255, 255)
set fx1=AddSpellEffectTargetById(s, EFFECT_TYPE_CASTER, clone, "origin" )
set fx2=AddSpellEffectTargetById(s, EFFECT_TYPE_TARGET, target, "origin" )
set mana=GetUnitFlyHeight( clone)
call SetUnitFlyHeight( clone, GetUnitFlyHeight(u) , 0)
call SetUnitFlyHeight( clone, mana , (mana-GetUnitFlyHeight(u))/CopyCat_MorphDelay(l))
call SetUnitAnimation(u, "spell")
call SetUnitTimeScale(clone, 0)
loop
exitwhen TimerGetRemaining(t) <= 0 or IsUnitDeadBJ(u)
call SetUnitVertexColor(clone,255,255,255, R2I( TimerGetElapsed(t)/CopyCat_MorphDelay(l)*255 )+1 )
call SetUnitVertexColor( u ,255,255,255, R2I( TimerGetRemaining(t)/CopyCat_MorphDelay(l)*255 )+1 )
call QueueUnitAnimation(u, "spell")
call TriggerSleepAction(0)
endloop
call IssueImmediateOrder(u, "stop")
call PauseUnit(u,false)
call DestroyEffect(fx1)
call DestroyEffect(fx2)
call SetUnitVertexColor(u,255,255,255,255)
if IsUnitDeadBJ(u) then
call RemoveUnit(clone)
return
endif
call SetUnitOwner( clone, GetOwningPlayer(u), false)
call SetUnitTimeScale(clone, 1)
set sel = IsUnitSelected( u, GetOwningPlayer(u) )
call ShowUnit(u, false)
call PauseUnit(clone,false)
call SetUnitPathing(clone,true)
call SetUnitInvulnerable(clone,false)
call SetUnitVertexColor(clone,255,255,255,255)
call SetUnitVertexColor(u,255,255,255,255)
set g=null
call AddSpellEffectTargetById( s, EFFECT_TYPE_EFFECT, clone, "origin" )
call UnitPauseTimedLife( clone, true)
call CopyCat_RemoveBadInventories( clone)
call UnitAddAbility(clone, CopyCat_Inventory())
set a=0
loop
exitwhen a>5
call UnitAddItem( clone, UnitItemInSlot(u,a) )
set a=a+1
endloop
call UnitAddAbility(clone, CopyCat_TurnOffSpellId())
call UnitMakeAbilityPermanent( clone, true, CopyCat_Inventory() )
call UnitMakeAbilityPermanent( clone, true, CopyCat_TurnOffSpellId() )
if sel then
call SelectUnitAddForPlayer( clone, GetOwningPlayer(u) )
endif
call CopyCat_MimicUnitHP(clone,u)
set mana=-1
if GetUnitState( clone, UNIT_STATE_MAX_MANA) <= 0 then
set mana=GetUnitState( u, UNIT_STATE_MANA)
endif
call SetUnitManaPercentBJ( clone, GetUnitManaPercent(u))
call SetHandleHandle( clone, "copycatrealunit", u)
call TriggerRegisterUnitEvent( ctrl, clone, EVENT_UNIT_DAMAGED)
call TriggerRegisterUnitEvent( ctrl, clone, EVENT_UNIT_SPELL_EFFECT)
call TriggerRegisterUnitEvent( dead, clone, EVENT_UNIT_DEATH)
call TriggerAddAction( ctrl, function CopyCat_Controller)
call TriggerAddAction( dead, function CopyCat_Dies)
if IsUnitType( target, UNIT_TYPE_HERO) then
call TimerStart( t, CopyCat_Duration(l)*CopyCat_HeroDurationFactor(l), false, null)
call SetUnitOwner(u,Player(15),false)
else
call TimerStart( t, CopyCat_Duration(l), false, null)
endif
loop
exitwhen GetTriggerEvalCount(dead)>0 or TimerGetRemaining(t) <= 0.0 or not IsUnitHidden(u)
call CopyCat_MimicUnitHP(u,clone)
call SetUnitManaPercentBJ( u, GetUnitManaPercent(clone))
call SetUnitFacing(u , GetUnitFacing(clone))
call TriggerSleepAction(0)
endloop
if mana>-1 then
call SetUnitState( u, UNIT_STATE_MANA, mana)
endif
call DestroyTrigger(dead)
if GetUnitState( clone, UNIT_STATE_MAX_LIFE) > 0 then
call CopyCat_Restore( clone,u)
endif
endif
call DestroyTimer(t)
call DestroyTrigger(dead)
call DestroyTrigger(ctrl)
set fx1=null
set fx2=null
set t=null
set target=null
set u=null
set clone=null
set dead=null
set ctrl=null
endfunction
//===================================================================================================
function InitTrig_CopyCat takes nothing returns nothing
set gg_trg_CopyCat = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CopyCat, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_CopyCat, Condition( function Trig_CopyCat_Conditions ) )
call TriggerAddAction( gg_trg_CopyCat, function Trig_CopyCat_Actions )
endfunction
//*****************************************************************************************************************
//*
//* Blaze
//* ¯¯¯¯¯
//* Requires:
//* - The Caster System( http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - The Blaze Ability
//* - This Trigger (Make sure it is using the right rawcode)
//* Art:
//* - The Ability's Area of effect art determines the flames' model
//* - The Ability's target art determines the damage per second effect
//* - The Ability's special art randomly spawns at the position of the flames
//* - The Ability's effect art is attached to the caster during the spell
//*
//*****************************************************************************************************************
//=================================================================================================================
// Flame Sweep Spell Configuration:
//
constant function Blaze_SpellId takes nothing returns integer
return 'A06G'
endfunction
constant function Blaze_FlameN takes integer level returns integer
return 4+3*level
endfunction
constant function Blaze_Duration takes real level returns real
return 10+5*level
endfunction
constant function Blaze_FlameDuration takes real level returns real
return 3+level
endfunction
constant function Blaze_Damage takes real level returns real
return 10+20*level
endfunction
constant function Blaze_Area takes real level returns real
return 75+25*level
endfunction
constant function Blaze_MinDistance takes real level returns real
return 55.0
endfunction
constant function Blaze_TargetAttachmentPoint takes nothing returns string
return "chest"
endfunction
//============================================================================================
function Trig_Blaze_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Blaze_SpellId()
endfunction
function Trig_Blaze_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u, s )
local timer t=CreateTimer()
local real x
local real y
local integer a=0
local integer n=0
local unit array flame
local real array spawn
local boolean b
local real e
local effect fx=AddSpellEffectTargetById( s, EFFECT_TYPE_EFFECT, u, "origin" )
set flame[0]=null
set spawn[0]=0 //Blaze_Duration(l)
call TimerStart( t, 100000 , false, null )
loop
set e=TimerGetElapsed(t)
exitwhen e>=Blaze_Duration(l) and n==0
set x=GetUnitX(u)
set y=GetUnitY(u)
set b=false
set a=0
loop
exitwhen a==n
if (e-spawn[a]) > Blaze_FlameDuration(l) then
set n=n-1
set spawn[a]=spawn[n]
set flame[a]=flame[n]
set flame[n]=null
else
if GetRandomInt(0,100) <= 15 then
call DestroyEffect( AddSpellEffectTargetById( s, EFFECT_TYPE_SPECIAL, flame[a] ,"origin" ) )
endif
if IsUnitInRange(u, flame[a], Blaze_MinDistance(l) ) then
set b=true
endif
set a=a+1
endif
endloop
if not(b) and n<Blaze_FlameN(l) and e<Blaze_Duration(l) then
set spawn[n]=e
set flame[n]=AddDamagingEffectEx( GetOwningPlayer(u), SpellEffectModelPath(s,EFFECT_TYPE_AREA_EFFECT), SpellEffectModelPath(s,EFFECT_TYPE_TARGET), Blaze_TargetAttachmentPoint(), GetUnitX(u)+GetRandomReal(-25,25),GetUnitY(u)+GetRandomReal(-25,25), Blaze_Damage(l) , 1, Blaze_FlameDuration(l), Blaze_Area(l), false )
set n=n+1
endif
call TriggerSleepAction(0)
endloop
call DestroyEffect(fx)
loop
set n=n-1
set flame[n]=null
exitwhen n==0
endloop
call DestroyTimer(t)
set t=null
set fx=null
set u=null
endfunction
//===========================================================================
function InitTrig_Blaze takes nothing returns nothing
set gg_trg_Blaze = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Blaze, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Blaze, Condition( function Trig_Blaze_Conditions ) )
call TriggerAddAction( gg_trg_Blaze, function Trig_Blaze_Actions )
endfunction
//*****************************************************************************************************************
//*
//* Lightning Guardians
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* - The Handle Variables Functions ( See the How to Implement category)
//* - The Lightning Guardians Ability
//* - A Guardian Unit (can be whatever you like and have the stats/ graphics
//* you preffer)
//* - This Trigger (Make sure it is using the right rawcodes)
//* Art:
//* - The Ability's special art is the spawn effect
//*
//* Note:
//* - This would only work as hero skill
//*
//*****************************************************************************************************************
//=================================================================================================================
// Last Breath Spell Configuration:
//
constant function LightningGuardians_SpellId takes nothing returns integer
return 'A06H' //// Lightning Guardians Ability Rawcode
endfunction
constant function LightningGuardians_UnitId takes nothing returns integer
return 'h01V' //// The Rawcode of the body guard unit
endfunction
constant function LightningGuardians_Aloced takes nothing returns boolean
return true //// Determines if the guardians are invulnerable
endfunction
constant function LightningGuardians_MaxDistance takes nothing returns real
return 1000.0 //// How far can a guardian be from its master
endfunction
constant function LightningGuardians_MinDistance takes nothing returns real
return 0.0 //// How close can a guardian be from its master
endfunction
function LightningGuardians_ComeCloseDist takes nothing returns real
return GetRandomReal(100,250)
endfunction
function LightningGuardians_CheckDelay takes nothing returns real
return GetRandomReal(0,0)
endfunction
//============================================================================================
function Trig_LightningGuardians_Conditions takes nothing returns boolean
return GetLearnedSkill() == LightningGuardians_SpellId()
endfunction
function LightningGuardians_AI takes nothing returns nothing
local unit summon=bj_ghoul[0]
local unit master=bj_ghoul[1]
local real x
local real y
local real angle
local real dist
local integer o
loop
exitwhen IsUnitDeadBJ(summon)
set x=GetUnitX(master)
set y=GetUnitY(master)
set o=GetUnitCurrentOrder(summon)
set dist=SquareRoot( Pow(x-GetUnitX(summon),2) + Pow(y-GetUnitY(summon),2) )
if IsUnitHidden(summon) then
elseif (dist > LightningGuardians_MaxDistance() ) and (o == 0 or o == OrderId("attack") or o == OrderId("move") or o == OrderId("stop") or o==851971) then
call IssuePointOrder(summon, "move", x,y)
elseif dist > LightningGuardians_MinDistance() and (o == 0 or o == 851971) then
set angle = GetRandomReal( 0,2*bj_PI)
set dist = LightningGuardians_ComeCloseDist()
call IssuePointOrder(summon, "attack", x+dist*Cos(angle),y+dist*Sin(angle) )
endif
call TriggerSleepAction( LightningGuardians_CheckDelay() ) //GetRandomReal(1.0,2.5))
endloop
set summon= null
set master = null
endfunction
function LightningGuardians_Guards takes unit u returns nothing
local unit array guard
local integer a
local integer l=0
local boolean b=false
local trigger ai=CreateTrigger()
local unit gh0
local unit gh1
call TriggerAddAction(ai, function LightningGuardians_AI )
call SetHandleInt(u,"LightningGuardiansDone",1)
loop
set a= GetUnitAbilityLevel(u, LightningGuardians_SpellId())
if a>l and not(b) then
set gh1=bj_ghoul[1]
set bj_ghoul[1]=u
loop
exitwhen l>=a
set guard[l] = CreateUnit( GetOwningPlayer(u), LightningGuardians_UnitId(), GetUnitX(u), GetUnitY(u), 0 )
call DestroyEffect( AddSpellEffectById(LightningGuardians_SpellId(),EFFECT_TYPE_SPECIAL, GetUnitX(guard[l]), GetUnitY(guard[l])) )
if LightningGuardians_Aloced() then
call UnitAddAbility( guard[l],'Aloc')
call UnitRemoveAbility( guard[l],'Aloc')
call SetUnitPathing( guard[l], true)
endif
call SetUnitInvulnerable( guard[l], true)
set gh0=bj_ghoul[0]
set bj_ghoul[0]=guard[l]
call TriggerExecute(ai)
set bj_ghoul[0]=gh0
set gh0=null
set l=l+1
endloop
set bj_ghoul[1]=gh1
set gh1=null
elseif a<l then
loop
exitwhen l<=a
set l=l-1
call ExplodeUnitBJ( guard[l] )
set guard[l]=null
endloop
endif
exitwhen a==0
if (IsUnitDeadBJ(u) or IsUnitHidden(u)) then
if not b then
set b=true
loop
set l=l-1
call ExplodeUnitBJ( guard[l] )
set guard[l] = null
exitwhen l<=0
endloop
endif
elseif b then
set b=false
endif
if l>=1 and GetOwningPlayer(u)!=GetOwningPlayer(guard[0]) then
set a=0
loop
call SetUnitOwner( guard[a], GetOwningPlayer(u), true)
set a=a+1
exitwhen a>=l
endloop
endif
call TriggerSleepAction(0)
endloop
call SetHandleInt(u,"LightningGuardiansDone",0)
call DestroyTrigger(ai)
set ai=null
endfunction
function Trig_LightningGuardians_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
if u==null then
set u=GetFilterUnit()
endif
if GetHandleInt(u,"LightningGuardiansDone") == 0 then
call LightningGuardians_Guards(u)
endif
set u=null
endfunction
function LightningGuardians_Check takes nothing returns nothing
if GetUnitAbilityLevel( GetFilterUnit(), LightningGuardians_SpellId() ) > 0 then
call TriggerExecute(gg_trg_LightningGuardians)
endif
endfunction
function InitTrig_LightningGuardians takes nothing returns nothing
set gg_trg_LightningGuardians = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_LightningGuardians, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_LightningGuardians, Condition( function Trig_LightningGuardians_Conditions ) )
call TriggerAddAction( gg_trg_LightningGuardians, function Trig_LightningGuardians_Actions )
call DestroyGroup( GetUnitsInRectMatching( bj_mapInitialPlayableArea, Condition(function LightningGuardians_Check) ) )
endfunction
//*****************************************************************************************************************
//*
//* Flame Sweep
//* ¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* - The Caster System( http://www.wc3campaigns.com/forumdisplay.php?f=534 )
//* - The Handle Variables Functions ( See the How to Implement category)
//* - The Flame Sweep Ability
//* - This Trigger (Make sure it is using the right rawcode)
//* Art:
//* - The Ability's Area of effect art determines the flames' model
//* - The Ability's target art determines the damage per second effect
//* - The Ability's special art randomly spawns at the position of the flames
//*
//*****************************************************************************************************************
//=================================================================================================================
// Flame Sweep Spell Configuration:
//
constant function FlameSweep_SpellId takes nothing returns integer
return 'A06I' //// Flame Sweep Ability Rawcode (changes between maps)
endfunction
function FlameSweep_FlameNumber takes integer level returns integer
return 3+level //// The number of flames that form the wall
endfunction
function FlameSweep_FlameDistance takes real level returns real
return 75+level*25 //// Distance between the flames
endfunction
function FlameSweep_Area takes real level returns real
return 100+25*level //// The area of effect for each flame
endfunction
function FlameSweep_InitialDamage takes real level returns real
return 35+15*level //// Initial damage to units in area of effect of the flame
endfunction
function FlameSweep_DamagePerSecond takes real level returns real
return 2.3+1.8*level //// Damage per second after last value
endfunction
function FlameSweep_DamageDuration takes real level returns real
return 7+2*level //// Duration of the damage per second.
endfunction
function FlameSweep_PushUnits takes nothing returns boolean
return true //// Is True when you want the spell to push units, false if you don't
endfunction
function FlameSweep_FlameScale takes real level returns real
return 0.9+0.1*level
endfunction
//================================================================================================================
function Trig_Flame_Sweep_Conditions takes nothing returns boolean
return GetSpellAbilityId() == FlameSweep_SpellId()
endfunction
function FlameSweep_GetLog takes handle h returns group
return GetHandleHandle(h, "targetlog")
endfunction
function FlameSweep_GetUnit takes handle h, string s returns unit
return GetHandleHandle(h,s)
endfunction
function FlameSweep_MoveUnits takes nothing returns nothing
local timer cro=GetExpiredTimer()
local group g=FlameSweep_GetLog( cro )
local real b
local unit u=FlameSweep_GetUnit( cro, "flamesweeper")
local integer l
local unit t
local real a
local real ux=GetUnitX(u)
local real uy=GetUnitY(u)
local real x
local real y
local real x2
local real y2
local group g2=CreateGroup()
set bj_wantDestroyGroup=false
call GroupAddGroup( g, g2 )
loop
set t=FirstOfGroup(g2)
exitwhen t==null
call GroupRemoveUnit(g2,t)
if IsUnitDeadBJ(t) then
call GroupRemoveUnit(g,t)
else
set x=GetUnitX(t)
set y=GetUnitY(t)
set a = SquareRoot( Pow(ux-x,2) + Pow(uy-y,2) )
set b= Atan2BJ(y-uy,x-ux )-2
set x2= GetUnitX(u)+a*CosBJ(b)
set y2= GetUnitY(u)+a*SinBJ(b)
call SetUnitPosition( t, x2,y2)
if SquareRoot( Pow(x2-GetUnitX(t),2) + Pow(y2-GetUnitY(t),2) ) > 20 then
call SetUnitPosition( t, x,y)
endif
endif
endloop
call DestroyGroup(g2)
set t=null
set u=null
set g=null
set g2=null
set cro=null
endfunction
function FlameSweep_InRange takes nothing returns nothing
local group g=FlameSweep_GetLog( GetTriggeringTrigger() )
local unit f=FlameSweep_GetUnit( GetTriggeringTrigger(), "GetFlame")
local integer l
local unit t=GetTriggerUnit()
if IsUnitEnemy(t,GetOwningPlayer(f)) then
if IsUnitInGroup(t,g) then
elseif not(IsUnitDeadBJ(t)) then
set l=GetHandleInt( f, "l" )
call DamageUnit( GetOwningPlayer(f), FlameSweep_InitialDamage(l), t)
call DamageUnitTimed( GetOwningPlayer(f), FlameSweep_DamagePerSecond(l), FlameSweep_DamageDuration(l), t, SpellEffectModelPath( FlameSweep_SpellId() ,EFFECT_TYPE_TARGET) , "chest" )
call GroupAddUnit(g,t)
endif
endif
set g=null
set f=null
set t=null
endfunction
function FlameSweep_Movement takes nothing returns nothing
local unit f=FlameSweep_GetUnit(GetExpiredTimer(),"flame")
local unit u=FlameSweep_GetUnit(f,"flamesweeper")
local real g=GetHandleReal(f,"angle")-2
local real d=GetHandleReal(f,"dist")
call SetHandleReal(f,"angle",g)
call SetUnitPosition(f, GetUnitX(u) + d*CosBJ(g), GetUnitY(u) + d*SinBJ(g) )
call SetUnitFacing(f, g+90 )
if GetRandomInt(0,100) <= 5 then
call DestroyEffect( AddSpellEffectById( FlameSweep_SpellId(),EFFECT_TYPE_SPECIAL, GetUnitX(f), GetUnitY(f) ) )
endif
set f=null
set u=null
endfunction
function Trig_Flame_Sweep_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local unit array flame
local effect array fx
local integer a=0
local integer n=FlameSweep_FlameNumber(l)
local location loc=GetSpellTargetLoc()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local real f= Atan2BJ( GetLocationY(loc)-y, GetLocationX(loc)-x )
local real g= f+90
local integer b=0
local real d
local trigger array tri
local group log=CreateGroup()
local timer array cronos
loop
exitwhen a>=n
set flame[a]=GetACaster()
call SetUnitScale( flame[a], FlameSweep_FlameScale(l), FlameSweep_FlameScale(l), FlameSweep_FlameScale(l) )
set d=FlameSweep_FlameDistance(l)*(a+1)
call SetHandleHandle(flame[a],"flamesweeper",u)
call SetHandleReal(flame[a],"angle",g)
call SetHandleReal(flame[a],"dist",d)
call SetUnitPosition( flame[a], x+d*CosBJ(g), y+d*SinBJ(g) )
set fx[a]=AddSpellEffectTargetById(s,EFFECT_TYPE_AREA_EFFECT,flame[a],"origin" )
call SetUnitOwner( flame[a], GetOwningPlayer(u), true)
set tri[a]=CreateTrigger()
call SetHandleHandle(tri[a], "targetlog",log)
call SetHandleHandle(tri[a], "GetFlame", flame[a] )
call TriggerAddAction( tri[a], function FlameSweep_InRange )
call TriggerRegisterUnitInRange( tri[a], flame[a], FlameSweep_Area(l), null )
call SetUnitFacing( flame[a], f)
set cronos[a]=CreateTimer()
call TimerStart(cronos[a], 0.04, true, function FlameSweep_Movement )
call SetHandleHandle(cronos[a],"flame",flame[a])
call SetHandleReal(cronos[a],"angle",g)
set a=a+1
endloop
if FlameSweep_PushUnits() then
set cronos[n]=CreateTimer()
call SetHandleHandle( cronos[n],"targetlog",log)
call SetHandleHandle( cronos[n],"flamesweeper",u)
call TimerStart(cronos[n], 0.04, true, function FlameSweep_MoveUnits )
endif
call PolledWait(3.6)
set a=0
set udg_delayhack=4
loop
exitwhen a>=n
call FlushHandleLocals(flame[a])
call RecicleCasterAfterCast( flame[a] , 0 )
call DestroyEffect(fx[a])
call FlushHandleLocals(tri[a])
call DestroyTrigger(tri[a])
call FlushHandleLocals(cronos[a])
call DestroyTimer(cronos[a])
set cronos[a]=null
set flame[a]=null
set fx[a]=null
set tri[a]=null
set a=a+1
endloop
if FlameSweep_PushUnits() then
call FlushHandleLocals(cronos[n])
call DestroyTimer( cronos[n])
set cronos[n]=null
endif
set udg_delayhack=0
call DestroyGroup(log)
call RemoveLocation(loc)
set log=null
set loc=null
endfunction
//================================================================================================================
function InitTrig_Flame_Sweep takes nothing returns nothing
set gg_trg_Flame_Sweep = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Flame_Sweep, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Flame_Sweep, Condition( function Trig_Flame_Sweep_Conditions ) )
call TriggerAddAction( gg_trg_Flame_Sweep, function Trig_Flame_Sweep_Actions )
endfunction
//***************************************************************************************************
//*
//* Terror
//* ¯¯¯¯¯¯
//* Requires:
//* - The Terror Ability
//* - The Terror Buff
//* - The Handle Variables Functions
//* - This Trigger (Make sure it points to the Terror Ability Rawcode)
//* Notes:
//* - The Spell considers the ability's Allowed Targets and buff duration, area must be
//* the same of the trigger.
//*
//***************************************************************************************************
//===================================================================================================
// Terror Spell Configuration
//
constant function Terror_SpellId takes nothing returns integer
return 'A06J' /// Terror Ability rawcode
endfunction
constant function Terror_BuffId takes nothing returns integer
return 'B00I' /// Terror Buff Rawcode
endfunction
constant function Terror_Area takes real level returns real
return 500.0 /// Should be much more than the area of the ability
endfunction
//===================================================================================================
function Trig_Terror_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Terror_SpellId()
endfunction
function Terror_GetUnit takes trigger t, string s returns unit
return GetHandleHandle(t,s)
endfunction
function Terror_Control takes nothing returns nothing
local unit s=GetTriggerUnit()
local unit u
local real a
local real x
local real y
if GetHandleInt(s,"Terror_IgnoreTrigger")==1 then
else
call SetHandleInt(s, "Terror_IgnoreTrigger",1)
set u=Terror_GetUnit(GetTriggeringTrigger(),"u")
set x=GetUnitX(s)
set y=GetUnitY(s)
set a=Atan2BJ(y-GetUnitY(u),x-GetUnitX(u))
if not IssuePointOrder(s,"move",x+CosBJ(a)*1000,y+SinBJ(a)*1000) then
call IssueImmediateOrder(s,"stop")
endif
call SetHandleInt(s, "Terror_IgnoreTrigger",0)
set u=null
endif
set s=null
endfunction
function Terror_Scares takes nothing returns nothing
local unit s=bj_meleeNearestMine
local unit u=GetTriggerUnit()
local trigger t=CreateTrigger()
local real x
local real y
local real a
call TriggerAddAction(t,function Terror_Control)
call TriggerRegisterUnitEvent(t,s,EVENT_UNIT_ISSUED_ORDER)
call TriggerRegisterUnitEvent(t,s,EVENT_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterUnitEvent(t,s,EVENT_UNIT_ISSUED_POINT_ORDER)
call SetHandleHandle(t,"u",u)
loop
exitwhen not UnitHasBuffBJ(s,Terror_BuffId())
call SetHandleInt(s, "Terror_IgnoreTrigger",1)
set x=GetUnitX(s)
set y=GetUnitY(s)
set a=Atan2BJ(y-GetUnitY(u),x-GetUnitX(u))
if not IssuePointOrder(s,"move",x+CosBJ(a)*1000,y+SinBJ(a)*1000) then
call IssueImmediateOrder(s,"stop")
endif
call SetHandleInt(s, "Terror_IgnoreTrigger",0)
call TriggerSleepAction(0)
endloop
call FlushHandleLocals(t)
call DestroyTrigger(t)
call SetHandleInt(s,"Terror_IgnoreTrigger",0)
set t=null
set s=null
set u=null
endfunction
function Trig_Terror_Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel(u,s)
local group g=CreateGroup()
local unit p
local trigger sep=CreateTrigger()
call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),Terror_Area(l),null)
call TriggerAddAction(sep,function Terror_Scares)
call TriggerSleepAction(0)
loop
set p=FirstOfGroup(g)
exitwhen p==null
if UnitHasBuffBJ(p,Terror_BuffId()) then
set bj_meleeNearestMine=p
call TriggerExecute(sep)
endif
call GroupRemoveUnit(g,p)
endloop
call DestroyTrigger(sep)
call DestroyGroup(g)
set g=null
set sep=null
set u=null
endfunction
//===================================================================================================
function InitTrig_Terror takes nothing returns nothing
set gg_trg_Terror = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Terror, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Terror, Condition( function Trig_Terror_Conditions ) )
call TriggerAddAction( gg_trg_Terror, function Trig_Terror_Actions )
endfunction