xAnaMorphine
Active Member
- Reaction score
- 43
new jasshelper is new...
thanks blackrose
the map works like a charm, huuuray :>
thanks blackrose
the map works like a charm, huuuray :>
.
struct projgroup
implement LinkedList
private projectile array list[MAX_PROJGROUP_SIZE]
private integer count = 0
//------------------------------------------------------------\\
// Destroy method: Clear all data and destroy the struct.
method destroy takes nothing returns nothing
call this.clear()
call this.detachThis()
call this.deallocate()
endmethod
//------------------------------------------------------------\\
// ForGroup method: Execute function for all projectiles.
method forGroup takes EnumEvents whichFunc returns nothing
local integer i = this.count - 1
loop
exitwhen i < 0
set EnumProjectile = this.list<i>
call whichFunc.evaluate()
set i = i - 1
endloop
endmethod
//------------------------------------------------------------\\
// Enum method: Group all nearby projectiles.
method enumNearby takes real x, real y, real z, real radius returns nothing
local projectile p = ProjectileList.head
local vector v = vector.create(x,y,z)
call this.clear()
loop
exitwhen p == 0
if p.posVect.isInSphere(v,radius) then
call this.add(p)
endif
set p = p.next
endloop
call v.destroy()
endmethod
//------------------------------------------------------------\\
// Remove method: Remove a projectile from a projgroup.
method remove takes projectile whichProj returns boolean
local integer i = this.count - 1
if whichProj != null and this.isInGroup(whichProj) then
call RemoveSavedBoolean(StorageHash,integer(this),integer(whichProj))
loop
exitwhen i < 0
if this.list<i> == whichProj then
set this.count = this.count - 1
set this.list<i> = this.list[this.count]
return true
endif
set i = i - 1
endloop
endif
return false
endmethod
//------------------------------------------------------------\\
// Add method: Add a projectile to a projgroup.
method add takes projectile whichProj returns boolean
if this.count < MAX_PROJGROUP_SIZE and whichProj != null and not this.isInGroup(whichProj) then
call SaveBoolean(StorageHash,integer(this),integer(whichProj),true)
set this.list[this.count] = whichProj
set this.count = this.count + 1
return true
endif
return false
endmethod
//------------------------------------------------------------\\
// Clear method: Clear all data from a projgroup.
method clear takes nothing returns nothing
local integer i = this.count - 1
loop
exitwhen i < 0
set this.list<i> = 0
set i = i - 1
endloop
set this.count = 0
call FlushChildHashtable(StorageHash,integer(this))
endmethod
//------------------------------------------------------------\\
// IsInGroup method: Check if a projectile is in a projgroup.
method isInGroup takes projectile whichProj returns boolean
return HaveSavedBoolean(StorageHash,integer(this),integer(whichProj))
endmethod
//------------------------------------------------------------\\
// FirstOfGroup method: Retrieve first projectile.
method firstOfGroup takes nothing returns projectile
return this.list[0]
endmethod
//------------------------------------------------------------\\
// Count method: Retrieve number of projectiles in projgroup.
method getCount takes nothing returns integer
return this.count
endmethod
//------------------------------------------------------------\\
// Projgroup creation.
static method create takes nothing returns thistype
return ProjGroupList.addToStart(thistype.allocate())
endmethod
endstruct
</i></i></i></i>
.
private function ForProjGroupCallback takes nothing returns nothing
set EnumProjectile = projectile[GetEnumUnit()]
call EnumEvents(ForGroupStack.top.callback).evaluate()
endfunction
struct projgroup
implement LinkedList
private integer max = 0
private group grp
//------------------------------------------------------------\\
// Destroy method: Clear all data and destroy the struct.
method destroy takes nothing returns nothing
static if LIBRARY_Recycle then
call Group.release(this.grp)
set this.grp = null
elseif LIBRARY_GroupUtils then
call ReleaseGroup(this.grp)
set this.grp = null
else
call GroupClear(this.grp)
endif
call this.detachThis()
call this.deallocate()
endmethod
//------------------------------------------------------------\\
// ForGroup method: Execute function for all projectiles.
method forGroup takes EnumEvents whichFunc returns nothing
call ForGroupStack.increment()
set ForGroupStack.top.callback = whichFunc
call ForGroup(this.grp,function ForProjGroupCallback)
call ForGroupStack.decrement()
endmethod
//------------------------------------------------------------\\
// Enum method: Group all nearby projectiles.
method enumNearby takes real x, real y, real z, real radius returns nothing
local projectile p = ProjectileList.head
local vector v = vector.create(x,y,z)
call this.clear()
loop
exitwhen p == 0
if p.posVect.isInSphere(v,radius) then
call this.add(p)
endif
set p = p.next
endloop
call v.destroy()
endmethod
//------------------------------------------------------------\\
// Remove method: Remove a projectile from a projgroup.
method remove takes projectile whichProj returns boolean
if whichProj != 0 then // and IsUnitInGroup(whichProj.dummy,this.grp) then
call GroupRemoveUnit(this.grp,whichProj.dummy)
set this.max = this.max - 1
return true
endif
return false
endmethod
//------------------------------------------------------------\\
// Add method: Add a projectile to a projgroup.
method add takes projectile whichProj returns boolean
if whichProj != 0 then // and not IsUnitInGroup(whichProj.dummy,this.grp) then
call GroupAddUnit(this.grp,whichProj.dummy)
set this.max = this.max + 1
return true
endif
return false
endmethod
//------------------------------------------------------------\\
// Clear method: Clear all data from a projgroup.
method clear takes nothing returns nothing
call GroupClear(this.grp)
set this.max = 0
endmethod
//------------------------------------------------------------\\
// IsInGroup method: Check if a projectile is in a projgroup.
method isInGroup takes projectile whichProj returns boolean
return IsUnitInGroup(whichProj.dummy,this.grp)
endmethod
//------------------------------------------------------------\\
// FirstOfGroup method: Retrieve first projectile.
method firstOfGroup takes nothing returns projectile
return projectile[FirstOfGroup(this.grp)]
endmethod
//------------------------------------------------------------\\
// Count method: Retrieve number of projectiles in projgroup.
method getCount takes nothing returns integer
return this.max
endmethod
//------------------------------------------------------------\\
// Projgroup creation.
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
static if LIBRARY_Recycle then
set this.grp = Group.get()
elseif LIBRARY_GroupUtils then
set this.grp = NewGroup()
else
if this.grp == null then
set this.grp = CreateGroup()
endif
endif
return ProjGroupList.addToStart(this)
endmethod
endstruct
method add takes projectile p returns boolean
if size < ENUM__storageMax and not inGroup(p) then
call SaveInteger(thistype.table, this, p, size)
set indexOf[size] = p
set size = size + 1
if not HaveSavedInteger(projGroupTable, p, 0) then
call SaveInteger(projGroupTable, p, 0, this)
call SaveInteger(projGroupTableReverse, p, this, 0)
call SaveInteger(projGroupTable, p, -1, 1)
else
call SaveInteger(projGroupTable, p, LoadInteger(projGroupTable, p, -1), this)
call SaveInteger(projGroupReverse, p, this, LoadInteger(projGroupTable, p, 0))
call SaveInteger(projGroupTable, p, -1, LoadInteger(projGroupTable, p, -1) + 1)
endif
return true
endif
return false
endmethod
method remove takes projectile p returns boolean
local integer index
local integer length
if inGroup(p) then
set size = size - 1
set indexOf[LoadInteger(thistype.table, this, p)] = indexOf[size]
call RemoveSavedInteger(thistype.table, this, p)
set length = LoadInteger(projGroupTable, p, -1) - 1
call SaveInteger(projGroupTable, p, -1, length)
call SaveInteger(projGroupTable, p, LoadInteger(projGroupTableReverse, p, this), length)
call SaveInteger(projGroupTableReverse, p, length, length)
if length == 0 then
call FlushChildHashtable(projGroupTable, p)
call FlushChildHashtable(projGroupTableReverse, p)
endif
return true
endif
return false
endmethod
if HaveSavedInteger(projGroupTable, this, 0) then
set i = LoadInteger(projGroupTable, this, -1)
loop
exitwhen i < 0
call projectilegroup(LoadInteger(projGroupTable, this, i)).remove(this)
set i = i - 1
endloop
endif
private function init takes nothing returns nothing
local projectilegroup pg = projectilegroup.create( )
local projectile p = projectile.create(null)
call pg.add(p)
if not pg.add(p) then
call BJDebugMsg("Didn039;t add. This is correct.")
endif
call p.kill( )
set p = projectile.create(null)
if pg.inGroup(p) then
call BJDebugMsg("Projectile is in group, but shouldn039;t be.")
endif
endfunction
method add takes projectile p returns boolean
local integer indexOfLast
if size < ENUM__storageMax and not inGroup(p) then
call SaveInteger(thistype.table, this, p, size)
set indexOf[size] = p
set size = size + 1
set indexOfLast = 0
if HaveSavedInteger(projGroupTable, p, -1) then
set indexOfLast = LoadInteger(projGroupTable, p, -1)
endif
call SaveInteger(projGroupTable, p, indexOfLast, this)
call SaveInteger(projGroupTableRev, p, this, indexOfLast)
call SaveInteger(projGroupTable, p, -1, indexOfLast + 1)
return true
endif
return false
endmethod
method remove takes projectile p returns boolean
local integer indexOfLast
local integer indexOfThis
if inGroup(p) then
set size = size - 1
set indexOf[LoadInteger(thistype.table, this, p)] = indexOf[size]
call RemoveSavedInteger(thistype.table, this, p)
set indexOfLast = LoadInteger(projGroupTable, p, -1) - 1
set indexOfthis = LoadInteger(projGroupTableRev, p, this)
call SaveInteger(projGroupTable, p, -1, indexOfLast)
call SaveInteger(projGroupTable, p, indexOfThis, LoadInteger(projGroupTable, p, indexOfLast))
call SaveInteger(projGroupTableRev, p, LoadInteger(projGroupTable, p, indexOfThis), indexOfThis)
if indexOfLast < 1 then
call FlushChildHashtable(projGroupTable, p)
call FlushChildHashtable(projGroupTableRev, p)
endif
return true
endif
return false
endmethod
Oh and I would really like to use the same "Slow Time" special effect model that you use in your test-map I was wondering if you were okay with that?
Nice work fixing the ghost projectile issue as well. I wish there was a less complicated way of doing it though..
P[ p ][ m ] = g
R[ p ][ g ] = m
P[ p ][ m ] = g
R[ p ][ g ] = m
P[ p ][ R[ p ][ g ] ] = g