- Joined
- Nov 23, 2008
- Messages
- 512
i have some problems with a jass system and a hash revive sys
1) Jass Unit Collision sys
The Problem:
I use it in a 0.03 loop (missle system) and it lag heaviely (after a secound launch of a missle wc3 has 0 fps.
The Code:
and a trigger that call the init
2) Revive with Hash
The Problem:
the unit doesn't spawn.
The Code:
Init:
1) Jass Unit Collision sys
The Problem:
I use it in a 0.03 loop (missle system) and it lag heaviely (after a secound launch of a missle wc3 has 0 fps.
The Code:
JASS:
function AddUnitCollision takes integer uID, real rad returns nothing
set udg_UC_Number = udg_UC_Number + 1
set udg_UC_Type[udg_UC_Number] = uID
set udg_UC_UnitRadius[udg_UC_Number] = rad
if rad > udg_UC_MaxCollisionsSize then
set udg_UC_MaxCollisionsSize =rad+1
endif
endfunction
function UnitCollisionInit takes nothing returns nothing
call AddUnitCollision('h004',110)
call AddUnitCollision('h001', 60)
call AddUnitCollision('h002', 65)
call AddUnitCollision('h005', 60)
call AddUnitCollision('h007', 80)
endfunction
function GetUnitCollSize takes unit u returns real
local integer i= 1
loop
exitwhen i >= udg_UC_Number
if GetUnitTypeId(u) == udg_UC_Type[i] then
set u=null
return udg_UC_UnitRadius[i]
endif
set i= i+1
endloop
set u=null
return 0.
endfunction
function CheckForCollision takes location loc, real z, player p, real CollSize returns boolean
local group g = GetUnitsInRangeOfLocMatching(udg_UC_MaxCollisionsSize,loc,null)
local unit u
local real array r
local boolean b = false
loop
set u =FirstOfGroup(g)
exitwhen u ==null or b ==true
if GetOwningPlayer(u) != p then
set r[0] = GetLocationX(loc) - GetUnitX(u)
set r[1] = GetLocationY(loc) - GetUnitY(u)
set r[2] = SquareRoot(r[0] * r[0] + r[1] * r[1])
set r[3] = GetUnitFlyHeight(u)-z
set r[4] = SquareRoot(r[2] * r[2] + r[3] * r[3])
if r[4] <= (GetUnitCollSize(u)-CollSize) then
call DestroyGroup(g)
call RemoveLocation(loc)
set loc=null
set p =null
set g =null
set u =null
return true
endif
endif
endloop
call DestroyGroup(g)
call RemoveLocation(loc)
set loc=null
set p =null
set g =null
set u =null
return false
endfunction
2) Revive with Hash
The Problem:
the unit doesn't spawn.
The Code:
Init:
-
Hash init
-
Ereignisse
- Map initialization
- Bedingungen
-
Aktionen
- Set CR_TimeBeforRevive = 10.00
- -------- ====================== --------
- Hashtabelle - Create a hashtable
- Set CR_Hash = (Last created hashtable)
- -------- ====================== --------
- Set CR_Enemys = Spieler 2 (Blau)
- -------- ====================== --------
- Custom script: set bj_wantDestroyGroup = true
-
Einheitengruppe - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Schleifen - Aktionen
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
'IF'-Bedingungen
- (Owner of (Picked unit)) Gleich CR_Enemys
-
'THEN'-Aktionen
- Einheitengruppe - Add (Picked unit) to CR_ReviveAbleGroup
- Set CR_LeakPoint = (Position of (Picked unit))
- Hashtabelle - Save Handle OfCR_LeakPoint as 0 of (Key (Picked unit)) in CR_Hash
- Hashtabelle - Save (Facing of (Picked unit)) as 1 of (Key (Picked unit)) in CR_Hash
- Custom script: call RemoveLocation(udg_CR_LeakPoint)
- 'ELSE'-Aktionen
-
'IF'-Bedingungen
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Schleifen - Aktionen
-
Ereignisse
-
Hash revive
-
Ereignisse
- Einheit - A unit Stirbt
-
Bedingungen
- ((Triggering unit) is in CR_ReviveAbleGroup) Gleich True
-
Aktionen
- Custom script: local location p = LoadLocationHandleBJ(0, GetHandleIdBJ(GetTriggerUnit()), udg_CR_Hash)
- Custom script: local real f = LoadRealBJ(1, GetHandleIdBJ(GetTriggerUnit()), udg_CR_Hash)
- Custom script: local integer ID = GetUnitTypeId(GetTriggerUnit())
- Spiel - Display to (All players) the text: locals created
- -------- ----------------------------------------------------------------- --------
- Custom script: call TriggerSleepAction( udg_CR_TimeBeforRevive )
- -------- ----------------------------------------------------------------- --------
- Custom script: call CreateUnitAtLoc(udg_CR_Enemys,ID,p,f)
- Custom script: call GroupAddUnitSimple( GetLastCreatedUnit(), udg_CR_ReviveAbleGroup )
- Spiel - Display to (All players) the text: create new unit
- -------- ----------------------------------------------------------------- --------
- Custom script: call SaveLocationHandleBJ( p, 0, GetHandleIdBJ(GetLastCreatedUnit()), udg_CR_Hash )
- Custom script: call SaveRealBJ( f, 1, GetHandleIdBJ(GetLastCreatedUnit()), udg_CR_Hash )
- Spiel - Display to (All players) the text: save hash
- -------- ----------------------------------------------------------------- --------
- Custom script: call RemoveLocation (p)
- Custom script: set p = null
-
Ereignisse