Hello again guys, I'm currently having trouble on a script that I edited. I've changed something on the damage lines. However it errors upon saving, so I guess what I did was wrong. Here's the code.....
Also this script uses this too...
I was trying to make the damage like 50 X level of ability + 50% of the hero's intelligence, I failed to do it and this is the error that appears
I've done this a lot of times on some of the spells in the spell section, however the codes in this spell pack are much different than the ones that I had edited.
JASS:
//Fire Bombs by Hanky aka OrkOfMordor aka MDZ-OrkOfMordor
scope FireBombs initializer init
//===================================================================================================================
//Constants
globals
private constant integer SpellId ='A007' //Ability Rawcode: Fire Bombs
private constant integer MaxMissiles =7 //The amount of the missiles
private constant integer DummyId ='e000' //Unit Rawcode: Dummy
private constant integer SpellBuffId ='A017' //Ability Rawcode: Fire Bombs - Effect
private constant real MaxRange =250.00 //The maximal area where the missiles can be thrown
private constant real MissileDamageRange =120.00 //The range of the damage
private constant real MaxTime =2.00 //The maximal time of the throw
private constant string ExplMdl ="Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl" //The explosion model
private constant string MissileMdl ="Abilities\\Weapons\\BatTrollMissile\\BatTrollMissile.mdl" //The missile model
private constant string MissileAttachPoint="origin"//The attach point of MissileMdl
private constant real periodic =0.25 //The periodic motion time
private integer array BuffData[maxIndex] //Important attached datas
endglobals
private function FB_MissileFlyHeight takes nothing returns real
//Random fly height of the missiles
return GetRandomReal(500,700)
endfunction
private function FB_Damage takes integer lvl, unit caster returns real
return 50.0 * lvl + GetHeroInt(caster, true)*0.50
endfunction
private constant function FB_Buff_Duration takes integer lvl returns real
//The duration of the burn buff
return 3.*lvl
endfunction
private constant function FB_Buff_Damage takes integer lvl returns real
//Damage per time for all burning units
return 5.*lvl
endfunction
private function UnitFilter takes unit c,unit u returns boolean
//The unit filter for the units who get damage
if IsUnitEnemy(u,GetOwningPlayer(c)) then
if GetUnitState(u,UNIT_STATE_LIFE)>0. then
if GetUnitAbilityLevel(u,invulnerable_id)<=0 then
if IsUnitType(u,UNIT_TYPE_FLYING)==false then
if IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)==false then
return IsUnitType(u,UNIT_TYPE_STRUCTURE)==false
endif
endif
endif
endif
endif
return false
endfunction
//End Constants
//===================================================================================================================
//Conditions
private function Fire_Bombs_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellId
endfunction
//Actions
private struct FireBombsBuff
unit caster
unit victim
real dmg
real time
real duration
method check takes nothing returns nothing
set .time=.time+periodic
call UnitDamageTarget(.caster,.victim,.dmg,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if not IsUnitNotBuffImmune(.victim) or .time>.duration then
call UnitRemoveAbility(.victim,SpellBuffId)
set .active=false
endif
endmethod
method endcheck takes nothing returns nothing
call ClearHandleIndex(.victim)
set .caster=null
set .victim=null
call .destroy()
endmethod
//! runtextmacro CostumMotion("FireBombsBuff","check","endcheck","periodic")
endstruct
private struct FireBombs
unit caster
unit missile
effect gfx
real dmg
integer lvl
method onDestroy takes nothing returns nothing
call DestroyEffect(.gfx)
call RemoveUnit(.missile)
set .caster =null
set .missile=null
set .gfx =null
endmethod
endstruct
private function FireBombsExpl takes nothing returns nothing
local timer t =GetExpiredTimer()
local FireBombs dat =GetTimerDataInt(t)
local FireBombsBuff datB
local integer id
local unit a
local group g
call DestroyEffect(AddSpecialEffect(ExplMdl,GetUnitX(dat.missile),GetUnitY(dat.missile)))
call DestroyEffect(dat.gfx)
set g=GetUnitsInRange(MissileDamageRange,GetUnitX(dat.missile),GetUnitY(dat.missile))
loop
set a=FirstOfGroup(g)
exitwhen a==null
call GroupRemoveUnit(g,a)
if UnitFilter(dat.caster,a) then
if GetUnitAbilityLevel(a,SpellBuffId)>0 then
call UnitRemoveAbility(a,SpellBuffId)
set id =GetHandleIndex(a)
set datB=BuffData[id]
else
call AddHandleIndex(a)
set id =GetHandleIndex(a)
set datB=FireBombsBuff.create()
call FireBombsBuff.addMotion(datB)
endif
call UnitDamageTarget(dat.caster,a,dat.dmg,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call UnitAddAbility(a,SpellBuffId)
call SetUnitAbilityLevel(a,SpellBuffId,dat.lvl)
set datB.caster =dat.caster
set datB.victim =a
set datB.dmg =FB_Buff_Damage(dat.lvl)*periodic
set datB.time =0.
set datB.duration =FB_Buff_Duration(dat.lvl)
set BuffData[id] =datB
endif
endloop
call dat.destroy()
call RecycleTimer(t)
set g=null
set t=null
endfunction
private function Fire_Bombs_Actions takes nothing returns nothing
local timer t
local real randomA =0
local real randomB =0
local real randomY =0
local real randomX =0
local integer int =1
local FireBombs dat
local unit u =GetTriggerUnit()
local real x =GetUnitX(u)
local real y =GetUnitY(u)
local real Rx =GetSpellTargetX()
local real Ry =GetSpellTargetY()
local integer lvl =GetUnitAbilityLevel(u,SpellId)
local player p =Player(14)
loop
exitwhen int>MaxMissiles
set randomA =GetRandomReal(0,360)
set randomB =GetRandomReal(0,MaxRange)
set randomX =Rx+randomB*Cos(randomA*deg2rad)
set randomY =Ry+randomB*Sin(randomA*deg2rad)
set dat =FireBombs.create()
set dat.caster =u
set dat.missile=CreateUnit(p,DummyId,x,y,0)
set dat.gfx =AddSpecialEffectTarget(MissileMdl,dat.missile,MissileAttachPoint)
set dat.lvl =lvl
set dat.dmg =FB_Damage (lvl)
set t =GetNextTimerInt(dat)
call LaunchMissileAtPointEx(dat.missile,x,y,45,FB_MissileFlyHeight(),randomX,randomY,0.,D2PXY(x,y,randomX,randomY)/MaxTime*MotionDatabase_periodic)
call TimerStart(t,MaxTime,false,function FireBombsExpl)
set int=int+1
endloop
set u =null
set p =null
set t =null
endfunction
//===========================================================================
private function init takes nothing returns nothing
local integer i=0
local unit upre
set gg_trg_Fire_Bombs = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_Fire_Bombs, Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT, Filter(function DebugFilter))
set i=i+1
exitwhen i==bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_Fire_Bombs, Condition( function Fire_Bombs_Conditions ) )
call TriggerAddAction( gg_trg_Fire_Bombs, function Fire_Bombs_Actions )
//Preload Buffs
set upre=CreateUnit(Player(14),DummyId,PreX,PreY,0)
call UnitAddAbility(upre,SpellBuffId)
call RemoveUnit(upre)
set upre=null
//Preload Models
call Preload(ExplMdl)
call Preload(MissileMdl)
endfunction
endscope
Also this script uses this too...
JASS:
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
// Û Û
// Û Û
// ßßßßßÛ Ûßßßßß
// Û Û
// Û Û ÜÜÜÜÜÜ ÜÜÜÜÜÜÜ
// Û Û Û Û Û Û
// Û Û Û Ü Û Û Ûßßßßßß
// Û Û Û ÛÛ Û Û Û
// Û Û Û Û Û Û Û Û ÜÜÜ
// Û Û Û Û Û Û Û Û Û Û
// Û Û Û ßßß Û Û ÛÜÜÛ Û
// Û Û Û Û Û Û
// ßßßß ßßßßßßßß ßßßßßßß
// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
// ³ Clan TDG @ Azeroth ¸ ³
// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
// Screen Solution: 1280x1024 Visit [url]www.jx3.net/TDG[/url]!
// ++++++++++++++++++++++++++++++++++++++++++ INFO ++++++++++++++++++++++++++++++++++++++++
// Type........................................ : .....................................Random
// Language.................................... : ......................................vJass
// Coder....................................... : ......................................Hanky
// MUI......................................... : ........................................Yes
// ++++++++++++++++++++++++++++++++++++++++++ CREDITS ++++++++++++++++++++++++++++++++++++++++
// Thanks for the JassGenNewPack: .............pipedream
// .............xttocs
// .............Pitzermike
// .............Vexorian
// .............MindWorx
// .............Scio
// .............Starcraftfreak
// .............FyreDaug
// .............KDEWolf
// ++++++++++++++++++++++++++++++++++++++++++ NOTES ++++++++++++++++++++++++++++++++++++++++
// Greetz fly out to: NgO . BuranX . JonNny . Darkt3mpl3r . WaRadius . Fireeye
// TDG . WC3C . HIVE . Toadcop . xxdingo93xx . Dynasti . TheBlooddancer
// Paladon
//================================================================================================
//Loop - Costum Motion
//================================================================================================
//A very useful system for looping structs. If you want to know more about this small system
//then check out our website. ("www.ngo.clan.su")
//! textmacro CostumMotion takes type,run,end,periodic
static timer loopExe=CreateTimer()
static integer size =0
static $type$ array runStruct[maxIndex]
boolean active
boolean paused
static method loopRun takes nothing returns nothing
local integer index=0
loop
exitwhen index==$type$.size
if not $type$.runStruct[index].paused then
if $type$.runStruct[index].active then
call $type$.runStruct[index].$run$()
set index=index+1
else
call $type$.runStruct[index].$end$()
set $type$.size=$type$.size-1
set $type$.runStruct[index]=$type$.runStruct[$type$.size]
endif
else
set index=index+1
endif
endloop
if $type$.size==0 then
call PauseTimer($type$.loopExe)
endif
endmethod
static method addMotion takes $type$ data returns integer
if $type$.size==0 then
call TimerStart($type$.loopExe,$periodic$,true,function $type$.loopRun)
endif
set $type$.runStruct[$type$.size] =data
set $type$.runStruct[$type$.size].active=true
set $type$.runStruct[$type$.size].paused=false
set $type$.size =$type$.size+1
return $type$.size
endmethod
//! endtextmacro
//================================================================================================
//Hashtable Index System
//================================================================================================
library HIS
globals
//Config Part
private constant integer size=8190
private constant integer pos =0
//Hashtable Var
private hashtable tempcache=InitHashtable()
//Important SystemVars
private integer array inUse[size]
private integer array last [size]
private integer indexsize=0
private integer lastsize =0
endglobals
//System Code
function AddHandleIndex takes handle h returns nothing
local integer id=GetHandleId(h)
local integer qi
if HaveSavedInteger(tempcache,id,pos) then
set qi=LoadInteger(tempcache,id,pos)
set inUse[qi]=inUse[qi]+1
elseif lastsize>0 then
set lastsize =lastsize-1
set inUse[last[lastsize]]=1
call SaveInteger(tempcache,id,pos,last[lastsize])
else
set inUse[indexsize]=1
call SaveInteger(tempcache,id,pos,indexsize)
set indexsize=indexsize+1
endif
endfunction
function GetHandleIndex takes handle h returns integer
debug if not HaveSavedInteger(tempcache,GetHandleId(h),pos) then
debug call BJDebugMsg("Error: No index attached to handle [#100]")
debug endif
return LoadInteger(tempcache,GetHandleId(h),pos)
endfunction
function ClearHandleIndex takes handle h returns nothing
local integer id=GetHandleId(h)
local integer qi=LoadInteger(tempcache,id,pos)
debug if HaveSavedInteger(tempcache,id,pos) then
set inUse[qi]=inUse[qi]-1
if inUse[qi]==0 then
set last[lastsize]=qi
set lastsize =lastsize+1
call FlushChildHashtable(tempcache,id)
endif
debug else
debug call BJDebugMsg("Error: No index attached to handle [#101]")
debug endif
endfunction
endlibrary
//================================================================================================
//Functions - Standart Functions
//================================================================================================
library MainFunctions initializer init
globals
constant real deg2rad =0.017453 //Set the degree to radians value
constant real rad2deg =57.2957795//Set the radians to degree value
constant integer maxIndex =8190 //Set the maximal index number
constant real PreX =700. //Preload X
constant real PreY =700. //Preload Y
public group loopG =null
public item getWalkable =null
public location loc =null
public boolexpr filter =null
constant integer invulnerable_id ='Avul'
constant integer purge_buff_id ='Bprg'
public constant integer getWalkable_id ='sehr'
public constant integer flyHack ='Amrf'
endglobals
function GetProVal takes real value returns real
if value<0. then
return value*-1
endif
return value
endfunction
//Little helpful functions
function ClearTextMessagesForPlayer takes player p returns nothing
if (GetLocalPlayer()==p) then
call ClearTextMessages()
endif
endfunction
function UnitAddFly takes unit u returns nothing
call UnitAddAbility(u,flyHack)
call UnitRemoveAbility(u,flyHack)
endfunction
function A2PXY takes real x,real y,real xt,real yt returns real
return ModuloReal(rad2deg*Atan2(yt-y,xt-x),360.)
endfunction
function D2PXY takes real x,real y,real xt,real yt returns real
local real dx=xt-x
local real dy=yt-y
return SquareRoot(dx*dx+dy*dy)
endfunction
function IsPointWalkable takes real x,real y returns boolean
call SetItemPosition(getWalkable,x,y)
call SetItemVisible(getWalkable,false)
return GetItemX(getWalkable)==x and GetItemY(getWalkable)==y
endfunction
function GetPointWalkableX takes real x,real y returns real
call SetItemPosition(getWalkable,x,y)
call SetItemVisible(getWalkable,false)
return GetItemX(getWalkable)
endfunction
function GetPointWalkableY takes real x,real y returns real
call SetItemPosition(getWalkable,x,y)
call SetItemVisible(getWalkable,false)
return GetItemY(getWalkable)
endfunction
function DebugFilter takes nothing returns boolean
return true
endfunction
function GetUnitsInRange takes real radius,real x,real y returns group
call GroupEnumUnitsInRange(loopG,x,y,radius,filter)
return loopG
endfunction
function GetClonedGroup takes group g returns group
set bj_groupAddGroupDest = loopG
call ForGroup(g, function GroupAddGroupEnum)
return loopG
endfunction
function RangedReal takes real v,real min,real max returns real
if v<min then
// return min
elseif v>max then
// return max
endif
return v
endfunction
function GetZ takes real x,real y returns real
call MoveLocation(loc,x,y)
return GetLocationZ(loc)
endfunction
//Credits to JonNny for the Parabula
function GetFlyParabula takes real maxheight , real zs , real zt , real q returns real
return (maxheight * Sin(q*bj_PI))+ q * (zt-zs)
endfunction
//Generic unit filter
function IsUnitNotImmun takes unit c,unit u returns boolean
if IsUnitEnemy(u,GetOwningPlayer(c)) then
if GetUnitState(u,UNIT_STATE_LIFE)>0. then
if GetUnitAbilityLevel(u,invulnerable_id)<=0 then
if IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)==false then
return IsUnitType(u,UNIT_TYPE_STRUCTURE)==false
endif
endif
endif
endif
return false
endfunction
function IsUnitNotBuffImmune takes unit u returns boolean
if IsUnitType(u,UNIT_TYPE_RESISTANT)==false then
if IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE)==false then
if GetUnitState(u,UNIT_STATE_LIFE)>0. then
if GetUnitAbilityLevel(u,invulnerable_id)<=0 then
return GetUnitAbilityLevel(u,purge_buff_id)<=0
endif
endif
endif
endif
return false
endfunction
function TerrainDeformationRippleXY takes real duration, boolean limitNeg, real x,real y, real startRadius, real endRadius, real depth, real wavePeriod, real waveWidth returns terraindeformation
local real spaceWave
local real timeWave
local real radiusRatio
if (endRadius <= 0 or waveWidth <= 0 or wavePeriod <= 0) then
return null
endif
set timeWave = 2.0 * duration / wavePeriod
set spaceWave = 2.0 * endRadius / waveWidth
set radiusRatio = startRadius / endRadius
set bj_lastCreatedTerrainDeformation = TerrainDeformRipple(x,y, endRadius, depth, R2I(duration * 1000), 1, spaceWave, timeWave, radiusRatio, limitNeg)
return bj_lastCreatedTerrainDeformation
endfunction
//Clearing Handles
function AB_DestroyTrigger takes trigger trig returns nothing
if trig!=null then
call TriggerClearActions(trig)
call TriggerClearConditions(trig)
call DestroyTrigger(trig)
endif
endfunction
function AB_DestroyTimer takes timer t returns nothing
if t!=null then
call PauseTimer(t)
call DestroyTimer(t)
endif
endfunction
function AB_DestroyGroup takes group g returns nothing
if g!=null then
call GroupClear(g)
call DestroyGroup(g)
endif
endfunction
function AB_DialogDestroy takes dialog log returns nothing
if log!=null then
call DialogClear(log)
call DialogDestroy(log)
endif
endfunction
function AB_DestroyMultiboard takes multiboard lb returns nothing
if lb!=null then
call MultiboardClear(lb)
call DestroyMultiboard(lb)
endif
endfunction
//Initialization of the varibales
private function init takes nothing returns nothing
set getWalkable=CreateItem(getWalkable_id,0,0)
set loc =Location(0,0)
set loopG =CreateGroup()
set filter =Filter(function DebugFilter)
call SetItemVisible(getWalkable,false)
endfunction
endlibrary
//Count function for rects in a area
library CountDestructable requires MainFunctions
globals
private rect dat_prove=Rect(0,0,0,0)
endglobals
private function EnumCountDestructables takes nothing returns nothing
if GetDestructableLife(GetEnumDestructable())>0 then
set bj_forLoopAIndex=bj_forLoopAIndex+1
endif
endfunction
function CountDestructableInRangeOfXY takes real x,real y,real range returns integer
call SetRect(dat_prove,x-range,y-range,x+range,y+range)
set bj_forLoopAIndex=0
call EnumDestructablesInRect(dat_prove,MainFunctions_filter,function EnumCountDestructables)
return bj_forLoopAIndex
endfunction
endlibrary
//================================================================================================
//Loop - Buff Check (Debug for some spells)
//================================================================================================
//This is just made for this spellpack. If you have questions about this system just ask me.
library BuffCheck requires MainFunctions
private struct BuffCheckData
integer buffid
real time
real max
unit u
method check takes nothing returns nothing
set .time=.time+0.5
set .active=.time<=.max and GetUnitAbilityLevel(.u,.buffid)>0
endmethod
method endcheck takes nothing returns nothing
call UnitRemoveAbility(.u,.buffid)
set .u=null
call .destroy()
endmethod
//! runtextmacro CostumMotion("BuffCheckData","check","endcheck","0.5")
endstruct
function DestroyBuffAfterTime takes unit u,integer buffid,real maxtime returns nothing
local BuffCheckData bc
if GetUnitAbilityLevel(u,buffid)>0 then
call UnitRemoveAbility(u,buffid)
else
set bc=BuffCheckData.create()
set bc.u =u
set bc.buffid=buffid
set bc.time =0.
set bc.max =maxtime
call BuffCheckData.addMotion(bc)
endif
endfunction
endlibrary
//================================================================================================
//Loop - Buff Effects
//================================================================================================
//This is just made for this spellpack. If you have questions about this system just ask me.
//! textmacro BuffEffect takes abilityId,periodic,prefix
private struct $prefix$BuffData
static timer loopExe=CreateTimer()
static integer size =0
static integer array executer [maxIndex]
static $prefix$BuffData array runStruct[maxIndex]
unit victim
real duration
real time
static method BuffCheck takes nothing returns nothing
local integer index=0
local integer id
loop
exitwhen index==$prefix$BuffData.size
set id=$prefix$BuffData.executer[index]
set $prefix$BuffData.runStruct[id].time=$prefix$BuffData.runStruct[id].time+$periodic$
if $prefix$BuffData.runStruct[id].time>=$prefix$BuffData.runStruct[id].duration then
call UnitRemoveAbility($prefix$BuffData.runStruct[id].victim,$abilityId$)
call ClearHandleIndex($prefix$BuffData.runStruct[id].victim)
set $prefix$BuffData.runStruct[id].victim=null
call $prefix$BuffData.runStruct[id].destroy()
set $prefix$BuffData.size=$prefix$BuffData.size-1
set $prefix$BuffData.executer[index]=$prefix$BuffData.executer[$prefix$BuffData.size]
elseif not IsUnitNotBuffImmune($prefix$BuffData.runStruct[id].victim) then
call UnitRemoveAbility($prefix$BuffData.runStruct[id].victim,$abilityId$)
call ClearHandleIndex($prefix$BuffData.runStruct[id].victim)
set $prefix$BuffData.runStruct[id].victim=null
call $prefix$BuffData.runStruct[id].destroy()
set $prefix$BuffData.size=$prefix$BuffData.size-1
set $prefix$BuffData.executer[index]=$prefix$BuffData.executer[$prefix$BuffData.size]
else
set index=index+1
endif
endloop
if $prefix$BuffData.size==0 then
call PauseTimer($prefix$BuffData.loopExe)
endif
endmethod
endstruct
private function UnitAdd$prefix$Buff takes unit victim,real duration,integer lvl returns nothing
local integer index
if $prefix$BuffData.size==0 then
call TimerStart($prefix$BuffData.loopExe,$periodic$,true,function $prefix$BuffData.BuffCheck)
endif
if GetUnitAbilityLevel(victim,$abilityId$)>0 then
set index=GetHandleIndex(victim)
call UnitRemoveAbility(victim,$abilityId$)
else
call AddHandleIndex(victim)
set index =GetHandleIndex(victim)
set $prefix$BuffData.runStruct[index] =$prefix$BuffData.create()
set $prefix$BuffData.executer[$prefix$BuffData.size]=index
set $prefix$BuffData.size =$prefix$BuffData.size+1
endif
set $prefix$BuffData.runStruct[index].victim =victim
set $prefix$BuffData.runStruct[index].duration =duration
set $prefix$BuffData.runStruct[index].time =0.
call UnitAddAbility(victim,$abilityId$)
call SetUnitAbilityLevel(victim,$abilityId$,lvl)
endfunction
//! endtextmacro
//================================================================================================
//Loop - Motion System
//================================================================================================
//This is a easy motion system which make some basic motions.
//It's helpful if you don't want to write some stuff again and
//again.
library MotionDatabase initializer init requires MainFunctions
globals
private constant real MinimalChaseRange=10.
public unit tm //Temp Missle
public unit tc //Temp Caster
public unit tv //Temp Victim
public integer tdata //Temp Data
private rect MaxArea =null
public real periodic =0.03
endglobals
struct JumpDatabase
unit u
real distance
real maxdistance
real angle
real speed
real x
real y
real mx
real my
real array z[3]
method motion takes nothing returns nothing
local real curv
local real x
local real y
local real z
set .distance=.distance+.speed
if .distance>.maxdistance then
call SetUnitFlyHeight(.u,GetUnitDefaultFlyHeight(.u),0)
set .active=false
else
set x=.x+.mx
set y=.y+.my
set z=GetZ(x,y)
set curv=GetFlyParabula(.z[1],.z[0],.z[2],.distance/.maxdistance) + (.z[0]-z)
if RectContainsCoords(MaxArea,x,y) then
call SetUnitPosition(.u,x,y)
set .x=x
set .y=y
endif
call SetUnitFlyHeight(.u,curv,0)
endif
endmethod
method endmotion takes nothing returns nothing
set .u=null
call .destroy()
endmethod
//! runtextmacro CostumMotion("JumpDatabase","motion","endmotion","periodic")
endstruct
struct ChaseDatabase
unit u
unit target
unit attacker
real speed
real z
real Rz
string endfunc
integer data
integer loopMember
method motion takes nothing returns nothing
local real Ux =GetUnitX(.u)
local real Uy =GetUnitY(.u)
local real Tx =GetUnitX(.target)
local real Ty =GetUnitY(.target)
local real distance =D2PXY(Ux,Uy,Tx,Ty)
local real angle
if distance>MinimalChaseRange then
set angle=Atan2(Ty-Uy,Tx-Ux)
set Ux=Ux+.speed*Cos(angle)
set Uy=Uy+.speed*Sin(angle)
call SetUnitPosition(.u,Ux,Uy)
call SetUnitFlyHeight(.u,.z,.Rz)
else
set .active=false
endif
endmethod
method endmotion takes nothing returns nothing
set tv =.target
set tm =.u
set tc =.attacker
set tdata=.data
call ExecuteFunc(.endfunc)
set .u =null
set .target =null
set .attacker=null
call .destroy()
endmethod
//! runtextmacro CostumMotion("ChaseDatabase","motion","endmotion","periodic")
endstruct
struct CollisionDatabase
unit u
unit attacker
real speed
real angle
real z
real Rz
real range
real distance
real x
real y
string endfunc
integer data
integer loopMember
method motion takes nothing returns nothing
local unit a
local group g
local integer c
set .distance=.distance-.speed
if .distance>0. then
set .x=.x+.speed*Cos(.angle)
set .y=.y+.speed*Sin(.angle)
call SetUnitPosition(.u,.x,.y)
call SetUnitFlyHeight(.u,.z,.Rz)
set g=GetUnitsInRange(.range,.x,.y)
set c=0
loop
set a=FirstOfGroup(g)
exitwhen a==null
call GroupRemoveUnit(g,a)
if IsUnitNotImmun(.attacker,a) and a!=.u then
set c=c+1
endif
endloop
call GroupClear(g)
set g=null
set .active=c<=0
else
set .active=false
endif
endmethod
method endmotion takes nothing returns nothing
set tc =.attacker
set tm =.u
set tdata=.data
call ExecuteFunc(.endfunc)
set .u =null
set .attacker=null
call .destroy()
endmethod
//! runtextmacro CostumMotion("CollisionDatabase","motion","endmotion","periodic")
endstruct
function LaunchMissileAtPointEx takes unit u,real x1,real y1,real bZ,real maxZ,real x2,real y2,real endz,real speed returns nothing
local JumpDatabase JD =JumpDatabase.create()
set JD.u =u
set JD.z[0] =GetZ(x1,y1)+bZ
set JD.z[1] =maxZ
set JD.z[2] =GetZ(x2,y2)+endz
set JD.x =x1
set JD.y =y1
set JD.speed =speed
set JD.distance =0.
set JD.maxdistance =D2PXY(x1,y1,x2,y2)
set JD.angle =Atan2(y2-y1,x2-x1)
set JD.mx =speed*Cos(JD.angle)
set JD.my =speed*Sin(JD.angle)
call UnitAddFly(u)
call SetUnitX(u,x1)
call SetUnitY(u,y1)
call JumpDatabase.addMotion(JD)
endfunction
function LaunchNormalChaseMissileAtPointEx takes unit attacker,unit missile,real x1,real y1,real z,unit victim,real speed,real Zrate,string colfunc,integer data returns nothing
local ChaseDatabase CD =ChaseDatabase.create()
set CD.u =missile
set CD.z =z
set CD.attacker =attacker
set CD.target =victim
set CD.speed =speed
set CD.endfunc =colfunc
set CD.Rz =Zrate
set CD.data =data
call UnitAddFly(missile)
call SetUnitX(missile,x1)
call SetUnitY(missile,y1)
call ChaseDatabase.addMotion(CD)
endfunction
function LaunchNormalCollisionMissileAtPointEx takes unit attacker,unit missile,real x1,real y1,real z,real x2,real y2,real speed,real range,string colfunc,integer data returns nothing
local CollisionDatabase CD =CollisionDatabase.create()
set CD.u =missile
set CD.attacker =attacker
set CD.z =z
set CD.Rz =0.
set CD.x =x1
set CD.y =y1
set CD.range =range
set CD.speed =speed
set CD.endfunc =colfunc
set CD.distance =D2PXY(x1,y1,x2,y2)
set CD.angle =Atan2(y2-y1,x2-x1)
set CD.data =data
call UnitAddFly(missile)
call SetUnitX(missile,x1)
call SetUnitY(missile,y1)
call CollisionDatabase.addMotion(CD)
endfunction
private function init takes nothing returns nothing
set MaxArea=bj_mapInitialPlayableArea
endfunction
endlibrary
//================================================================================================
//Timer - Timer Recycler
//================================================================================================
//This is a standart timer recycler. It's so fast like TimerUtils and some benchmark tests
//showed that this system seems to be sometimes faster than both TimerUtil versions.
//But try it out yourself.
library TimerRecycler requires MainFunctions,HIS
globals
private constant integer pos =0
private hashtable hs =InitHashtable()
private integer lastsize =0
private timer array last[maxIndex]
endglobals
//! textmacro NextTimer takes name,type,func
function GetNextTimer$name$ takes $type$ dat returns timer
local integer index
local timer temp
if lastsize>0 then
set lastsize=lastsize-1
set temp =last[lastsize]
else
set temp =CreateTimer()
endif
call AddHandleIndex(temp)
call Save$func$(hs,GetHandleIndex(temp),pos,dat)
return temp
endfunction
//! endtextmacro
//! runtextmacro NextTimer("Int","integer","Integer")
//! runtextmacro NextTimer("Agent","agent","AgentHandle")
//! runtextmacro NextTimer("TextTag","texttag","TextTagHandle")
//! runtextmacro NextTimer("Lightning","lightning","LightningHandle")
//! textmacro GetType takes name,type,func
function GetTimerData$name$ takes timer t returns $type$
return Load$func$(hs,GetHandleIndex(t),pos)
endfunction
//! endtextmacro
//! runtextmacro GetType("Int","integer","Integer")
//! runtextmacro GetType("Unit","unit","UnitHandle")
//! runtextmacro GetType("Effect","effect","EffectHandle")
//! runtextmacro GetType("Lightning","lightning","LightningHandle")
//! runtextmacro GetType("TextTag","texttag","TextTagHandle")
function RecycleTimer takes timer t returns nothing
local integer index=GetHandleIndex(t)
call PauseTimer(t)
call ClearHandleIndex(t)
set last[lastsize]=t
set lastsize =lastsize+1
endfunction
endlibrary
//================================================================================================
//Group - Group Recycler
//================================================================================================
//A standart group recycler.
library GroupRecycler requires MainFunctions,HIS
globals
private integer max =0
private integer cmax =0
private group array rGroup
private integer array rInt[maxIndex]
endglobals
function GetNextGroup takes nothing returns group
set cmax=cmax+1
if max<cmax then
set rGroup[cmax]=CreateGroup()
set max =cmax
endif
call AddHandleIndex(rGroup[cmax])
set rInt[GetHandleIndex(rGroup[cmax])]=cmax
return rGroup[cmax]
endfunction
function RecycleGroup takes group g returns nothing
local integer index=GetHandleIndex(g)
call ClearHandleIndex(g)
set rGroup[rInt[index]] =rGroup[cmax]
set rInt[GetHandleIndex(rGroup[cmax])]=rInt[index]
set rGroup[cmax] =g
set cmax=cmax-1
endfunction
endlibrary
//================================================================================================
//Timed - Handle Destroy
//================================================================================================
//Some small useful functions.
library TimedHandleDead requires MainFunctions,TimerRecycler
function U2Death takes nothing returns nothing
local timer t = GetExpiredTimer()
call RemoveUnit(GetTimerDataUnit(t))
call RecycleTimer(t)
set t=null
endfunction
function U2Null takes unit u,real duration returns nothing
local timer t = GetNextTimerAgent(u)
call TimerStart(t,duration,false,function U2Death)
set t = null
endfunction
function E2Death takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyEffect(GetTimerDataEffect(t))
call RecycleTimer(t)
set t=null
endfunction
function E2Null takes effect e,real duration returns nothing
local timer t = GetNextTimerAgent(e)
call TimerStart(t,duration,false,function E2Death)
set t = null
endfunction
function L2Death takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyLightning(GetTimerDataLightning(t))
call RecycleTimer(t)
set t=null
endfunction
function L2Null takes lightning l,real duration returns nothing
local timer t = GetNextTimerLightning(l)
call TimerStart(t,duration,false,function L2Death)
set t = null
endfunction
function TT2Death takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyTextTag(GetTimerDataTextTag(t))
call RecycleTimer(t)
set t=null
endfunction
function TT2Null takes texttag tt,real duration returns nothing
local timer t = GetNextTimerTextTag(tt)
call TimerStart(t,duration,false,function L2Death)
set t = null
endfunction
endlibrary
//================================================================================================
//Passiv - Damage Skill
//================================================================================================
//This system will be useful for skills like my Crush or Holy Shock spell. For more
//informations just ask me.
library DamageSkill initializer init requires MainFunctions,TimerRecycler
globals
private boolexpr array ExecuteFunction[maxIndex]
private unit array Attacker[maxIndex]
private unit array Attacked[maxIndex]
private trigger DamageDetect=null
private trigger EventExecute=null
private group InUseCache =null
private group RegisterCache =null
public unit attacker=null
public unit attacked=null
public real damage =0.
endglobals
function TriggerAddDamageEvent takes unit a,unit b,code func returns nothing
local integer id
if not IsUnitInGroup(a,RegisterCache) then
call TriggerRegisterUnitEvent(DamageDetect,a,EVENT_UNIT_DAMAGED)
call GroupAddUnit(RegisterCache,a)
endif
if not IsUnitInGroup(b,InUseCache) then
call AddHandleIndex(b)
set id=GetHandleIndex(b)
call GroupAddUnit(InUseCache,b)
else
set id=GetHandleIndex(b)
call DestroyBoolExpr(ExecuteFunction[id])
endif
set ExecuteFunction[id]=Filter(func)
set Attacker[id] =b
set Attacked[id] =a
endfunction
private function CheckRegister takes nothing returns boolean
return IsUnitInGroup(GetEventDamageSource(),InUseCache)
endfunction
private function GetDamage takes nothing returns nothing
local integer id =GetHandleIndex(GetEventDamageSource())
local triggercondition tc
set attacker=Attacker[id]
set attacked=Attacked[id]
set damage =GetEventDamage()
set tc=TriggerAddCondition(EventExecute,ExecuteFunction[id])
call TriggerEvaluate(EventExecute)
call TriggerRemoveCondition(EventExecute,tc)
call DestroyBoolExpr(ExecuteFunction[id])
call GroupRemoveUnit(InUseCache,Attacker[id])
call ClearHandleIndex(Attacker[id])
set ExecuteFunction[id]=null
set Attacker[id] =null
set Attacked[id] =null
set tc =null
endfunction
private function init takes nothing returns nothing
set InUseCache =CreateGroup()
set RegisterCache =CreateGroup()
set DamageDetect =CreateTrigger()
set EventExecute =CreateTrigger()
call TriggerAddAction(DamageDetect,function GetDamage)
call TriggerAddCondition(DamageDetect,Condition(function CheckRegister))
endfunction
endlibrary
I was trying to make the damage like 50 X level of ability + 50% of the hero's intelligence, I failed to do it and this is the error that appears

I've done this a lot of times on some of the spells in the spell section, however the codes in this spell pack are much different than the ones that I had edited.