Dummy Leak

zepho

New Member
Reaction score
0
Hey I have some spell here. What it does is it fires an arcing axe missile to a point then when it lands, it explodes dealing damage and some slow stuff. My problem is when I fire this spell consecutively, the other missiles are stuck in the air and when I launch another one, the entire trigger doesn't work at all. All it does is create a dummy unit. Please help me :p

JASS:
scope DemolitionAxe initializer DemolitionAxe_Init // Replace scopename by name of trigger
 
globals
private constant real TIMEOUT = 0.03125
 
private constant integer SPELL_ABILITY_ID = 'A01H'
private constant integer DUMMY_ABILITY_ID = 'A02X'
private constant real SPEED = 800.
private constant real DAMAGE = 50.
private constant real RADIUS = 345. // AOE
private constant string MODEL = "Abilities\\Weapons\\RexxarMissile\\RexxarMissile.mdl"
private constant string EFFECT = "abilities\\weapons\\DemolisherMissile\\DemolisherMissile.mdl"
private constant string D_ATTACH_POINT = "chest"
private constant string T_ATTACH_POINT = "origin"
 
endglobals
 
private struct data
// Moving
unit caster
unit dummy
unit dummy2
effect e
 
//Math
real x
real y
real tx
real ty
real ox
real oy
real sin
real cos
real dist
real odist
real tdist
real v
real height
real angle
 
real damage
group damaged
 
static integer count=0
static group g = CreateGroup()
static timer time = CreateTimer()
 
static filterfunc filter
 
static data temp
static data array array
 
 
static method Start takes unit caster , unit dummy , location cast_loc returns data
local data this = data.allocate()
// Maths
local real x = GetUnitX(dummy)
local real y = GetUnitY(dummy)
local real tx = GetLocationX(cast_loc)
local real ty = GetLocationY(cast_loc)
local real dx = tx-x
local real dy = ty-y
local real angle = Atan2(dy,dx)
set .caster = caster
set .dummy = dummy
set .dummy2 = dummy2
set .cos = Cos(angle)
set .sin = Sin(angle)
set .dist = SquareRoot(dx*dx+dy*dy)
set .ox = GetUnitX(caster)
set .oy = GetUnitY(caster)
set .x = x
set .y = y
set .tx = tx
set .ty = ty
set .angle = angle
set .v = SPEED*TIMEOUT
set .height = 0.
set .odist = SquareRoot((.tx-.ox)*(.tx-.ox)+(.ty-.oy)*(.ty-.oy))
call RemoveLocation(cast_loc)
 
// Damage Formula
set .damage = DAMAGE+125.*GetUnitAbilityLevel(caster,SPELL_ABILITY_ID)
 
call SetUnitFlyHeight(.dummy,.height,0.)
set .e = AddSpecialEffectTarget(MODEL,.dummy,D_ATTACH_POINT)
call RemoveLocation(cast_loc)
call UnitAddAbility(.dummy,'Arav')
call UnitRemoveAbility(.dummy,'Arav')
call SetUnitScale(.dummy,2.5,2.5,2.5)
 
// Groups
if .damaged == null then
set .damaged = CreateGroup()
else
call GroupClear(.damaged)
call GroupClear(.g)
endif
// Timer
if .count == 0 then
call TimerStart(time,TIMEOUT,true,function data.Loop)
endif
set .array[.count] = this
set .count = .count + 1
// Return
return this
endmethod
 
private static method Loop takes nothing returns nothing
local integer i = 0
local data this
loop
exitwhen i>=.count
set this=.array
// Set X&Y
set .x = .x + (.v * .cos)
set .y = .y + (.v * .sin)
 
set .dist = SquareRoot((.tx-GetUnitX(.dummy))*(.tx-GetUnitX(.dummy))+(.ty-GetUnitY(.dummy))*(.ty-GetUnitY(.dummy))) - .v
set .tdist = SquareRoot((GetUnitX(.dummy)-.ox)*(GetUnitX(.dummy)-.ox)+(GetUnitY(.dummy)-.oy)*(GetUnitY(.dummy)-.oy)) - .v
 
// Move
call SetUnitX(.dummy,.x)
call SetUnitY(.dummy,.y)
 
if .height<=.odist/8 then
set .height = 5. + (.tdist/(.odist/2)) * (.odist/8)
endif
if .height>.odist/8 then
set .height = (.dist/(.odist/2)) * (.odist/8)
endif
 
call SetUnitFlyHeight(.dummy,.height,0.)
set .temp=this
 
if .dist<=0. then
// Resetting Values and Destroy Struct
call PauseTimer(.time)
call SetUnitFlyHeight(.dummy,0.,0.)
set dummy2 = CreateUnit(GetOwningPlayer(.caster),'u000',.x,.y,.angle)
call UnitAddAbility(.dummy2,DUMMY_ABILITY_ID)
call SetUnitAbilityLevel(.dummy2,DUMMY_ABILITY_ID,GetUnitAbilityLevel(.caster,SPELL_ABILITY_ID))
call IssueImmediateOrder(.dummy2,"thunderclap")
call GroupEnumUnitsInRange(.g,.x,.y,RADIUS,.filter)
call RemoveUnit(.dummy)
 
call DestroyEffect(.e)
call SetUnitScale(.dummy2,2.,2.,1.)
call DestroyEffect(AddSpecialEffectTarget(EFFECT,.dummy2,D_ATTACH_POINT))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl",.dummy2,"origin"))
call UnitApplyTimedLife(.dummy2,'u000',1.)
set .e=null
call .destroy()
 
set .count=.count-1
if .count>0 then
set .array=.array[.count]
 
set i=i-1
else
 
endif
endif
set i=i+1
endloop
endmethod
 
private static method Damage takes nothing returns boolean
local unit temp = GetFilterUnit()
if not IsUnitType(temp,UNIT_TYPE_STRUCTURE) and IsUnitEnemy(temp, GetOwningPlayer(.temp.caster)) and GetWidgetLife(temp)>=.405 and not IsUnitInGroup(temp,.temp.damaged) then
call GroupAddUnit(.temp.damaged,temp)
call UnitDamageTarget(.temp.caster,temp,.temp.damage,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNIVERSAL,null)
endif
set temp=null
return false
endmethod
 
private static method onInit takes nothing returns nothing
set .filter = Filter(function data.Damage)
endmethod
endstruct
 
function DemolitionAxe_Actions takes nothing returns nothing
local data dat = data.create()
local unit caster = GetTriggerUnit()
local location cast_loc = GetSpellTargetLoc()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real dx = GetLocationX(cast_loc)-x
local real dy = GetLocationY(cast_loc)-y
local real angle = bj_RADTODEG*Atan2(dy,dx)
local unit dummy = CreateUnit(GetOwningPlayer(caster),'u005',x,y,angle)
call data.Start(caster,dummy,cast_loc)
set caster=null
set dummy=null
set cast_loc=null
endfunction
private function DemolitionAxe_Init takes nothing returns nothing
local trigger t = CreateTrigger()
call GT_RegisterStartsEffectEvent(t,SPELL_ABILITY_ID)
call TriggerAddAction(t, function DemolitionAxe_Actions)
set t = null
endfunction
endscope

I think I have a problem with cleaning the dummy units when the trigger ends.

EDIT: I knew what caused me an error. The PauseTimer(.time) should have been placed in the else function. Thanks btw. :D
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
It looks like an indexing problem. Right here:
JASS:
set .count = .count - 1
if .count > 0 then
    set .array<i> = .array[count]
    set i = i - 1
else 
endif</i>

If you have a stack of instances:
1 - 2 - 3 - 4 - 5; count = 5
And deallocate index 2:
count = 4
array[2] = array[4]
thus:
1 - 4 - 3 - 4
Which leaves out 5. To fix that, you have to set it to the last before decrementing:
JASS:
set .array<i> = .array[count]
set .count = .count - 1
set i = i - 1</i>
 

zepho

New Member
Reaction score
0
Oh I see. But I fixed it already, the timer thingy seemed to have a problem. But Ill check that one too. :) Thanks btw.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Nevermind, you can probably ignore my post. I just realized that you start at 0 and count is always 1 more than your highest index, so you have it right in your post. Guess I was sleepy.

Glad you got it fixed though.

P.S. You should place your functions above where you call it from (if it is feasible). Otherwise vJASS will generate extra garbage code in order to run it properly. ex: move Loop above Start. It may seem trivial, but you can sometimes end up with copies of functions (which adds a decent amount of size to the war3map.j and you will often end up with prototype triggers. vJASS doesn't automatically reorder the methods.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top