HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Odd ability issue

03-22-2008, 03:31 AM#1
notsoexpert
While making an ability, I came to an odd impasse. When I test the follow spell:
Expand Intercept:
The results of this spell at level 1 are as follows (with debug mode on):
Text showing "24.000" appears (which is the hero's starting strength)
The hero "blinks" to the target location, the first two effects are spawned and one seemingly random unit gets damaged and knocked back (thanks to emjlr3 for the knockback system :)). No other text appears onscreen, the hero does not get healed and the healing effect does not spawn.
Upon multiple castings, the same unit that was "randomly" picked is the only one that gets knocked back each time.

Any ideas? I'm stumped...
03-22-2008, 04:05 AM#2
Rising_Dusk
Your thread is crashing.
Collapse JASS:
set dmgcnt = dmgcnt + dmg
You don't initialize the variable "dmgcnt" and this is causing your thread to crash at that point, meaning nothing else happens.
03-22-2008, 04:07 AM#3
Castlemaster
A couple of things that could be changed:
Collapse JASS:
private function filter takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) and (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) > 0.
endfunction
the second two arguments are "unit is not a structure" and "unit is alive", In reality you could omit those two to just:
Collapse JASS:
private function filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit()))
endfunction

The unit is not getting healed because you declare the variable "dmgcnt" but you don't define it, so it is null. Meaning when you get to this line:

Collapse JASS:
debug call BJDebugMsg(R2S(dmgcnt))
    set dmgcnt = dmgcnt * (I2R(lvl) * .05)
debug call BJDebugMsg(R2S(dmgcnt))
    call SetUnitState(u,UNIT_STATE_LIFE,(GetUnitState(u,UNIT_STATE_LIFE) + dmgcnt))
dmgcnt is null so neither the text nor the heal occurs

Also, if you are healing units, it's faster to use the commands "GetWidgetLife()" and "SetWidgetLife()".

The healing special effect might not show because some effects don't show if you destroy them immediately while others do.

I do not know why the knockback isn't working, but put in a debug message that says the name of "m" on each loop. That should shed some light on it.

Next time please explain what you want the spell to do before saying what is wrong with it. It helps us help you.

Also sorry if my explanations are haphazard, but your questions were.
03-22-2008, 04:14 AM#4
notsoexpert
@Castlemaster: Good point... It helps when you proofread your posts... sorry about that.

I had no idea you had to set a real to some value before you could do anything with it. So changing the declaration to local real dmgcnt = 0. should fix it?

I don't want intercept to attempt to damage and knockback structures or units, so I added those lines. What good would come of leaving them out?

I love optimizing. Any other tips? :)
03-22-2008, 04:17 AM#5
Rising_Dusk
Quote:
So changing the declaration to local real dmgcnt = 0. should fix it?
Yeap, that's it, it'll run after you do that.
03-22-2008, 04:28 AM#6
notsoexpert
And, upon testing, it works beautifully. Thanks! I was really worried that I broke something there...