- Joined
- Mar 3, 2006
- Messages
- 1,564
Ciebron once gave me a script for making a nova spell as following
There is a line that I don't understand
Dat.Ar is an integer and Dat is a struct of type NovaData how can I equalize them; they are of different type ?
JASS:
library NovaSystem initializer Init
//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
//= Nova System By Ciebron *=
//= *=
//= Version Alpha 1.1 *=
//= *=
//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*Setup Starts=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
//=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
globals
private constant integer Max_numberDummys = 36
private constant real Interval = 0.03
private boolexpr Bool
private integer Struct
endglobals
private struct NovaData
unit u
unit array dummy [Max_numberDummys]
player P
group g
integer Count
real dist
real x
real y
real array cos [Max_numberDummys]
real array sin [Max_numberDummys]
real damage
real MDist
real Aoe
string EndEffect
attacktype AtkType
damagetype DmgType
static group Group = CreateGroup()
static integer Total = 0
static integer array Ar
static timer Time = CreateTimer()
static integer index
static unit TempU
static real X
static real Y
static method createnova takes unit u,real dmg,real x,real y,real aoe,real time,integer count,integer Dummy_id,attacktype Atktype,damagetype Dmgtype,string createeff,string endeff returns nothing
local NovaData Dat = NovaData.allocate()
local integer i = 0
local real a = 0
local real ai
set Dat.u = u
set Dat.x = x
set Dat.y = y
set Dat.P = GetOwningPlayer(Dat.u)
set Dat.dist = 0.
set Dat.damage = dmg
set Dat.MDist = (aoe/time)/(1./Interval)
set Dat.g = CreateGroup()
set Dat.Aoe = aoe
set Dat.EndEffect = endeff
if createeff != "" then
call DestroyEffect(AddSpecialEffect(createeff,Dat.x,Dat.y))
endif
if count > Max_numberDummys then
set count = Max_numberDummys
endif
set ai = 360/count
set Dat.Count = count
loop
exitwhen i >= count
set Dat.dummy[i] = CreateUnit(Dat.P,Dummy_id,x,y,a)
set Dat.cos[i] = Cos(a*0.01745)
set Dat.sin[i] = Sin(a*0.01745)
set a = a + ai
set i = i + 1
endloop
if Dat.Total == 0 then
call TimerStart(Dat.Time,Interval,true,function NovaData.Loop)
endif
set Dat.Ar[Dat.Total] = Dat
set Dat.Total = Dat.Total + 1
endmethod
static method Loop takes nothing returns nothing
local NovaData Dat
local integer i = 0
loop
exitwhen i >= Dat.Total
set Dat = Dat.Ar[i]
set Dat.index = 0
set Dat.dist = Dat.dist + Dat.MDist
loop
exitwhen Dat.index >= Dat.Count
call SetUnitX(Dat.dummy[Dat.index],Dat.x+Dat.dist*Dat.cos[Dat.index])
call SetUnitY(Dat.dummy[Dat.index],Dat.y+Dat.dist*Dat.sin[Dat.index])
set Dat.index = Dat.index + 1
endloop
set Struct = Dat
call GroupEnumUnitsInRange(Dat.Group,Dat.x,Dat.y,Dat.dist,Bool)
loop
set Dat.TempU = FirstOfGroup(Dat.Group)
exitwhen Dat.TempU == null
call GroupRemoveUnit(Dat.Group,Dat.TempU)
call GroupAddUnit(Dat.g,Dat.TempU)
call UnitDamageTarget(Dat.u,Dat.TempU,100,false,false,Dat.AtkType,Dat.DmgType,null)
endloop
if Dat.dist >= Dat.Aoe then
set Dat.index = 0
loop
exitwhen Dat.index >= Dat.Count
if Dat.EndEffect != "" then
set Dat.X = GetUnitX(Dat.dummy[Dat.index])
set Dat.Y = GetUnitY(Dat.dummy[Dat.index])
call DestroyEffect(AddSpecialEffect(Dat.EndEffect,Dat.X,Dat.Y))
endif
call KillUnit(Dat.dummy[Dat.index])
set Dat.index = Dat.index + 1
endloop
set Dat.Total = Dat.Total - 1
set Dat.Ar[i] = Dat.Ar[Dat.Total]
set i = i - 1
call Dat.destroy()
endif
set i = i + 1
endloop
if Dat.Total == 0 then
call PauseTimer(Dat.Time)
endif
endmethod
static method UnitFilter takes nothing returns boolean
local NovaData Dat = Struct
local unit f = GetFilterUnit()
local boolean ok = GetWidgetLife(f) >= .305 and IsUnitEnemy(f,Dat.P) and not IsUnitType(f,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitInGroup(f,Dat.g)
set f = null
return ok
endmethod
method onDestroy takes nothing returns nothing
local integer i = 0
set .u = null
loop
exitwhen i >= .Count
set .dummy[i] = null
set i = i + 1
endloop
endmethod
endstruct
function CreateNova takes unit u,real dmg,real x,real y,real aoe,real time,integer count,integer dummy_id,attacktype AtkType,damagetype DmgType,string createE,string endE returns nothing
call NovaData.createnova(u,dmg,x,y,aoe,time,count,dummy_id,AtkType,DmgType,createE,endE)
endfunction
private function Init takes nothing returns nothing
set Bool = Filter(function NovaData.UnitFilter)
endfunction
endlibrary
There is a line that I don't understand
set Dat.Ar[Dat.Total] = Dat
Dat.Ar is an integer and Dat is a struct of type NovaData how can I equalize them; they are of different type ?