• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Simple Spell Help (JASS)

Status
Not open for further replies.
Level 13
Joined
Nov 22, 2006
Messages
1,260
Hello everybody,

I am creating a spell, more precise, remaking an existing spell from GUI to JASS. I'm an experienced jasser, so I have no idea why can't I find the problem in such a simple spell. Here's what the spell does (passive): It's supposed to create an orb above the caster, the orb grows every time the hero is attacked, until it grows to 100% of his original size. Then it is destroyed and it casts an ability on the unit who hit the last. The problem is that the orb is not showing, I don't know why. I tried detecting it with PingMinimap, and it shows that the orb is in the position of the caster, how it should be. That's a little weird, because I don't see it. Here's the code (it has 2 triggers):

JASS:
constant function NorthrendShield_SpellId takes nothing returns integer
    return 'A00I'
endfunction

constant function NorthrendShield_OrbDamageId takes nothing returns integer
    return 'A00J'
endfunction

constant function NorthrendShield_OrbId takes nothing returns integer
    return 'h00B'
endfunction

constant function NorthrendShield_HitsRequired takes nothing returns real
    return 20.0
endfunction

//===========================================================================

function Trig_Northrend_Shield_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), NorthrendShield_SpellId()) > 0
endfunction

function Trig_Northrend_Shield_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetAttacker()
    local unit u = GetHandleUnit(c, "o")
    local integer h = GetHandleInt(c, "h")
    local real r = 1/NorthrendShield_HitsRequired()
    if h == 0 then
        set u = CreateUnit(GetOwningPlayer(c), NorthrendShield_OrbId(), GetUnitX(c), GetUnitY(c), 0)
    endif
    set h = h + 1
    call BJDebugMsg(R2S(r))
    call SetHandleInt(c, "h", h)
    call SetHandleHandle(c, "o", u)
    call SetUnitScale(u, r * h, r * h, r * h)
    if h == R2I(NorthrendShield_HitsRequired()) then
        call SetUnitAbilityLevel(u, NorthrendShield_OrbDamageId(), GetUnitAbilityLevel(c, NorthrendShield_SpellId()))
        call IssueTargetOrder(u, "shadowstrike", t)
        call UnitApplyTimedLife(u, 'BTLF', 0.01)
        call SetHandleInt(c, "h", 0)
        call SetHandleHandle(c, "o", null)
    endif
    set c = null
    set t = null
    set u = null
endfunction

//===========================================================================

function NorthrendShield_OrbMoveFilter takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), NorthrendShield_SpellId()) > 0
endfunction

function NorthrendShield_OrbMoveActions takes nothing returns nothing
    local group g = CreateGroup()
    local boolexpr b = Condition(function NorthrendShield_OrbMoveFilter)
    local unit u
    local unit o
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, b)
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g, u)
        set o = GetHandleUnit(u, "o")
        if o != null then
            call SetUnitX(o, GetUnitX(u))
            call SetUnitY(o, GetUnitY(u))
        endif
    endloop
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set g = null
    set b = null
    set o = null
endfunction

//===========================================================================
function InitTrig_Northrend_Shield takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    set gg_trg_Northrend_Shield = CreateTrigger()
    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Northrend_Shield, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(gg_trg_Northrend_Shield, Condition(function Trig_Northrend_Shield_Conditions))
    call TriggerAddAction(gg_trg_Northrend_Shield, function Trig_Northrend_Shield_Actions)
    call TriggerRegisterTimerEvent(t, 0.035, true)
    call TriggerAddAction(t, function NorthrendShield_OrbMoveActions)
    set t = null
endfunction

I checked the rawcodes couple of times, but unfortunately, they are correct. Also, the orb doesn't cast the ability when the hits reaches 20, and it should. Integer h is raising like it should, so there's no problem there.

Thanks in advance :)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
What do you mean by art? I put some orbs on the map, tested it, and they were there, showing. There shouldn't be a problem with the orb. On the first hit, the orb should be created, and on the rest of them (until the 20th hit) should make it grow. And when it reaches 20, it starts all over again. Grrr.....I hate debugging
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
I meant the attachment point, and the effect. (you DID make sure the attachment point was right, right?)

Attachment point? I'm setting the orb's position every 0.035 seconds, there is no attachment point.

You don't need to destroy your filter (and why do you use Condition, not Filter?)

Yeah I know. Condition and Filter are the same, I think there is no known difference, but I've heard Condition is better. Haha I know something that you don't!!!

I made it work, for some reason it just started working. Strange are the ways of JASS......thanks for trying to help me
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Interesting... link?

Uhmm no link, sorry.... :). Someone told me that when I started a thread asking what's the difference between those two, but I can't seem to find it. Maybe it's on wc3c, but it's down again.

And sorry bout the attachment point misunderstanding

Np, just don't let it happen again :), haha I'm kidding. Thanks, you've been really helpful, but I can't rep you, first I have to spread it ;)
 
Status
Not open for further replies.
Top