Hi all,
I'm beginning with vJass, and wanted to make my first spells, but my result was, that my vJass triggers lagged extremely. Here is it in vJass:
and now in GUI
Why is the vJass trigger lagging with 20 units near to the casting unit and the GUI triggers not??
//EDIT: Oh yeah, of course +rep for helpers
I'm beginning with vJass, and wanted to make my first spells, but my result was, that my vJass triggers lagged extremely. Here is it in vJass:
JASS:
scope Gravity initializer Gravity
struct variables
//constants
real grav = 4
real duration = 50
real interval = 0.03
integer ab = 'A001'
real range = 500
//others
unit caster
real time = 0
endstruct
private function TriggerCond takes nothing returns boolean
return GetSpellAbilityId() == 'A001'
endfunction
private function Destroy takes timer t returns nothing
local variables dat = LoadIntegerBJ(2 , GetHandleIdBJ(t), structs)
call dat.destroy()
call FlushChildHashtableBJ(GetHandleIdBJ(t), structs)
call DestroyTimer(t)
endfunction
private function TimerCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local location array p
local group g
local real facing
local variables dat = LoadIntegerBJ(2 , GetHandleIdBJ(t), structs)
set p[1] = GetUnitLoc(dat.caster)
set g = GetUnitsInRangeOfLocAll(dat.range, p[1])
loop
exitwhen FirstOfGroup(g) == null
if IsUnitEnemy(FirstOfGroup(g), GetOwningPlayer(dat.caster)) == true and IsUnitDeadBJ(FirstOfGroup(g)) != true and IsUnitType(FirstOfGroup(g), UNIT_TYPE_STRUCTURE) != true then
set p[3] = GetUnitLoc(FirstOfGroup(g))
set facing = AngleBetweenPoints(p[3], p[1])
if DistanceBetweenPoints(p[1], p[3]) > 80 then
set p[2] = PolarProjectionBJ(p[3], dat.grav, facing+80)
call SetUnitPositionLoc(FirstOfGroup(g), p[2])
call RemoveLocation(p[2])
set p[2] = null
call RemoveLocation(p[3])
set p[3] = null
endif
endif
call GroupRemoveUnit(g, FirstOfGroup(g))
endloop
call RemoveLocation(p[1])
set p[1] = null
call DestroyGroup(g)
set g = null
set dat.time = dat.time + dat.interval
if dat.time >= GetUnitAbilityLevel(dat.caster, 'A001') * dat.duration or IsUnitDeadBJ(dat.caster) == true then
call PauseTimer(t)
call Destroy(t)
endif
endfunction
private function Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local timer t = CreateTimer()
local variables dat = variables.create()
set dat.caster = caster
call SaveTimerHandleBJ(t, 1, GetHandleIdBJ(t), structs)
call SaveIntegerBJ(dat, 2, GetHandleIdBJ(t), structs)
call TimerStart(t, dat.interval, true, function TimerCallback)
endfunction
//===========================================================================
private function Gravity takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerAddCondition ( t , Condition(function TriggerCond))
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction( t, function Actions )
endfunction
endscope
and now in GUI
-
Gravity1
-
Ereignisse
-
Einheit - A unit Beginnt, eine Fähigkeit zu wirken
-
-
Bedingungen
-
(Ability being cast) Gleich Gravity
-
-
Aktionen
-
Custom script: local unit u = GetSpellAbilityUnit()
-
Custom script: call SaveRealBJ(7, 1, GetHandleId(u), structs)
-
Custom script: call SaveUnitHandleBJ(u, 0, GetHandleId(u), structs)
-
Wait 50.00 seconds
-
Custom script: call FlushChildHashtable(structs, GetHandleId(u))
-
-
-
Gravity2
-
Ereignisse
-
Zeit - Every 0.03 seconds of game time
-
-
Bedingungen
-
Aktionen
-
Set temp_group[1] = (Units in (Playable map area))
-
Einheitengruppe - Pick every unit in temp_group[1] and do (Actions)
-
Schleifen - Aktionen
-
Custom script: if LoadUnitHandleBJ(0, GetHandleId(GetEnumUnit()), structs) != null then
-
Set temp_point[1] = (Position of (Picked unit))
-
Set temp_group[2] = (Units within 500.00 of temp_point[1] matching ((((Matching unit) is dead) Ungleich True) and (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Gleich True)))
-
Einheitengruppe - Pick every unit in temp_group[2] and do (Actions)
-
Schleifen - Aktionen
-
Set temp_point[2] = (Position of (Picked unit))
-
Set temp_point[3] = (temp_point[2] offset by 4.00 towards ((Angle from temp_point[2] to temp_point[1]) + 80.00) degrees)
-
Custom script: call RemoveLocation(udg_temp_point[2])
-
Custom script: call SetUnitX(GetEnumUnit(), GetLocationX(udg_temp_point[3]))
-
Custom script: call SetUnitY(GetEnumUnit(), GetLocationY(udg_temp_point[3]))
-
Custom script: call RemoveLocation(udg_temp_point[3])
-
-
-
Custom script: call DestroyGroup(udg_temp_group[2])
-
Custom script: call RemoveLocation(udg_temp_point[1])
-
Custom script: endif
-
-
-
Custom script: call DestroyGroup(udg_temp_group[1])
-
-
Why is the vJass trigger lagging with 20 units near to the casting unit and the GUI triggers not??
//EDIT: Oh yeah, of course +rep for helpers
Last edited: