spell nuke leaks possibly

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

darkxion
Member
Posts: 57
Joined: April 26th, 2007, 7:53 pm

spell nuke leaks possibly

Post by darkxion »

K..so, firstly, sorry if this code is an eyesore, most likely it's just custom text of GUI and not true JASS, but it's all I have to work with. Whenever the hero casts this spell (A0BT), after it finishes FPS drops massively, 5-10 points and doesn't come back. I would guess that is a leak but I have no idea why, any help would be greatly appreciated. Thanks!
Spoiler:

Code: Select all

function O112219 takes nothing returns boolean
	return(DistanceBetweenPoints(GetUnitLoc(udg_unit102),udg_location29)<=100.00)
endfunction

function O112321 takes nothing returns boolean
	return(IsPlayerEnemy(GetOwningPlayer(udg_unit102),GetOwningPlayer(GetFilterUnit()))==true)
endfunction

function O112387 takes nothing returns boolean
	return(DistanceBetweenPoints(GetUnitLoc(udg_unit102),GetUnitLoc(GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(100.00,GetUnitLoc(udg_unit102),Condition(function O112321)))))<=100.00)
endfunction

function O112467 takes nothing returns boolean
	return GetBooleanOr(O112219(),O112387())
endfunction

function O112526 takes nothing returns boolean
	if(not(GetSpellAbilityId()=='A0BT'))then
		return false
	endif
	return true
endfunction

function O112549 takes nothing returns boolean
	if(not(GetSpellAbilityId()=='A0C0'))then
		return false
	endif
	return true
endfunction

function O112648 takes nothing returns nothing
	if(O112526())then
		set udg_location29=GetSpellTargetLoc()
		set udg_Loc1=GetUnitLoc(GetSpellAbilityUnit())
		call CreateNUnitsAtLoc(1,'h01Q',GetOwningPlayer(GetSpellAbilityUnit()),udg_Loc1,GetUnitFacing(GetSpellAbilityUnit()))
		call RemoveLocation(udg_Loc1)
		set udg_unit102=GetLastCreatedUnit()
		call SetUnitVertexColorBJ(udg_unit102,0.00,0.00,100.00,0)
		call SetUnitScalePercent(udg_unit102,100.00,100.00,100.00)
		call IssuePointOrderLocBJ(udg_unit102,"move",udg_location29)
		loop
			exitwhen(O112467())
			call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL,0.10))
		endloop
		call RemoveLocation(udg_location29)
		set udg_location29=GetUnitLoc(udg_unit102)
		call RemoveUnit(udg_unit102)
		call CreateNUnitsAtLoc(1,'h01R',GetOwningPlayer(GetSpellAbilityUnit()),udg_location29,bj_UNIT_FACING)
		call UnitAddAbilityBJ('A0BU',GetLastCreatedUnit())
		call SetUnitAbilityLevelSwapped('A0BU',GetLastCreatedUnit(),GetUnitAbilityLevelSwapped('A0BT',GetSpellAbilityUnit()))
		call IssueImmediateOrderBJ(GetLastCreatedUnit(),"thunderclap")
		set bj_forLoopBIndex=1
		set bj_forLoopBIndexEnd=15
		loop
			exitwhen bj_forLoopBIndex>bj_forLoopBIndexEnd
			set udg_Loc1=PolarProjectionBJ(udg_location29,GetRandomReal(1.00,500.00),GetRandomReal(1.00,360.00))
			call AddSpecialEffectLocBJ(udg_Loc1,"Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl")
			call DestroyEffectBJ(GetLastCreatedEffectBJ())
			call RemoveLocation(udg_Loc1)
			set bj_forLoopBIndex=bj_forLoopBIndex+1
		endloop
		call RemoveLocation(udg_location29)
	else
	endif
	if(O112549())then
		set udg_unit103=GetSpellAbilityUnit()
		call UnitAddAbilityBJ('A0BZ',udg_unit103)
		call SetUnitAbilityLevelSwapped('A0BZ',udg_unit103,GetUnitAbilityLevelSwapped('A0C0',udg_unit103))
		call PolledWait((4.00*I2R(GetUnitAbilityLevelSwapped('A0C0',udg_unit103))))
		call UnitRemoveAbilityBJ('A0BZ',udg_unit103)
		set udg_unit103=null
	else
	endif
endfunction

function InitTrig_nuke takes nothing returns nothing
set gg_trg_nuke=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_nuke,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(gg_trg_nuke,function O112648)
endfunction
Thanks! I shall mull over this and try to figure it out with the new insight xD
Last edited by darkxion on August 13th, 2009, 12:36 am, edited 1 time in total.
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: spell nuke leaks possibly

Post by Risen »

Ok, this is what you need to do;

Download Jass NewGen Pack 1.5b

Find a 1.21 world editor, place it somewhere in an installed wc3 directory (preferably a "dummy" one)

Start it, enter your code, then for each function, say, "DistanceBetweenPoints", look it up in the function list, it should say "function DistanceBetweenPoints takes location something returns real"

Now, note the "takes location", that means it can leak if you give it something like "GetLocation()"

So you set it in a variable like this
Spoiler:

Code: Select all

function O112321 takes nothing returns boolean
local unit u = GetFilterUnit()
local player p = GetOwningPlayer(udg_unit102)
local player p2 = GetOwningPlayer(u)
   return(IsPlayerEnemy(p,p2)==true)
set u = null
set p = null
set p2 = null
endfunction
Take note, try not to "Destroy units you're gonna use in the future, same thing with players, so just null them, however, if it's something like "GetLocation()", then just set it in a variable, use it, then do "call RemoveLocation( l ), "l", is the variable name you might have set it in.

Anyways, functions I can spot that leak;
Spoiler:

Code: Select all

function O112321 takes nothing returns boolean
   return(IsPlayerEnemy(GetOwningPlayer(udg_unit102),GetOwningPlayer(GetFilterUnit()))==true)
endfunction

function O112387 takes nothing returns boolean
   return(DistanceBetweenPoints(GetUnitLoc(udg_unit102),GetUnitLoc(GroupPickRandomUnit(GetUnitsInRangeOfLocMatching(100.00,GetUnitLoc(udg_unit102),Condition(function O112321)))))<=100.00)
endfunction

function O112648 takes nothing returns nothing
   if(O112526())then
      set udg_location29=GetSpellTargetLoc()
      set udg_Loc1=GetUnitLoc(GetSpellAbilityUnit())
      call CreateNUnitsAtLoc(1,'h01Q',GetOwningPlayer(GetSpellAbilityUnit()),udg_Loc1,GetUnitFacing(GetSpellAbilityUnit()))
      call RemoveLocation(udg_Loc1)
      set udg_unit102=GetLastCreatedUnit()
      call SetUnitVertexColorBJ(udg_unit102,0.00,0.00,100.00,0)
      call SetUnitScalePercent(udg_unit102,100.00,100.00,100.00)
      call IssuePointOrderLocBJ(udg_unit102,"move",udg_location29)
      loop
         exitwhen(O112467())
         call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL,0.10))
      endloop
      call RemoveLocation(udg_location29)
      set udg_location29=GetUnitLoc(udg_unit102)
      call RemoveUnit(udg_unit102)
      call CreateNUnitsAtLoc(1,'h01R',GetOwningPlayer(GetSpellAbilityUnit()),udg_location29,bj_UNIT_FACING)
      call UnitAddAbilityBJ('A0BU',GetLastCreatedUnit())
      call SetUnitAbilityLevelSwapped('A0BU',GetLastCreatedUnit(),GetUnitAbilityLevelSwapped('A0BT',GetSpellAbilityUnit()))
      call IssueImmediateOrderBJ(GetLastCreatedUnit(),"thunderclap")
      set bj_forLoopBIndex=1
      set bj_forLoopBIndexEnd=15
      loop
         exitwhen bj_forLoopBIndex>bj_forLoopBIndexEnd
         set udg_Loc1=PolarProjectionBJ(udg_location29,GetRandomReal(1.00,500.00),GetRandomReal(1.00,360.00))
         call AddSpecialEffectLocBJ(udg_Loc1,"Abilities\\Weapons\\FrostWyrmMissile\\FrostWyrmMissile.mdl")
         call DestroyEffectBJ(GetLastCreatedEffectBJ())
         call RemoveLocation(udg_Loc1)
         set bj_forLoopBIndex=bj_forLoopBIndex+1
      endloop
      call RemoveLocation(udg_location29)
   else
   endif
   if(O112549())then
      set udg_unit103=GetSpellAbilityUnit()
      call UnitAddAbilityBJ('A0BZ',udg_unit103)
      call SetUnitAbilityLevelSwapped('A0BZ',udg_unit103,GetUnitAbilityLevelSwapped('A0C0',udg_unit103))
      call PolledWait((4.00*I2R(GetUnitAbilityLevelSwapped('A0C0',udg_unit103))))
      call UnitRemoveAbilityBJ('A0BZ',udg_unit103)
      set udg_unit103=null
   else
   endif
endfunction



Now, take note, integers, reals, and I think booleans(haven't coded in jass for a while) do not leak.
Image
Wanna learn to hack maps? --> Guide