• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Need help with bugs in spell

Status
Not open for further replies.
Level 2
Joined
Jan 8, 2018
Messages
12
Hi,
I recently started working with JASS. I've been practicing making spells, and I have an incomplete spell which I need some help with. In its current iteration, it should:
  1. Create the visual effect of Warstomp around caster
  2. Launch the caster into the air, then bring them back down
  3. Warstomp again upon collision with the ground
The spell works by starting a recurring timer when the spell is cast, and updating the casters fly height each time the timer expires based on how long the caster's been in the air. When the caster's fly height would be <0, the caster lands, causing a warstomp visual effect. The warstomp also occurs when the spell is cast. The caster is able to move around normally while the spell is in effect.

My spell has 3 1 0 bugss:
  1. Even though I give the caster Crow Form and remove it, the caster's fly height can't be changed - the caster remains visually grounded and GetUnitFlyHeight(caster) returns 0 regardless of what I try to set the value to.
  2. Even though the Warstomp effect gets called twice, the effect only displays once each time the spell is cast (the initial Warstomp, and not when the caster lands).
  3. I based the spell off of Immolation, because I want the ability to be toggleable and drain mana/second (in the final build, the caster will continue to bounce until the ability is deactivated). I want the caster to have a custom buff which has a unique visual effect and the right buff tooltip, but even when I strip my Immolation copy of all of its art and buff properties, it still displays the immolation buff art/icon/tooltip upon activation, and I'm unable to make the spell apply the custom buff. Furthermore, I can't even remove the immolation buff by calling "UnitRemoveBuffBJ('BEim', caster)". How do I remove the immolation buff and add my own custom buff? Is there some secret menu where I can make my spell point to my custom buff, rather than to the immolation buff?
Below is the updated code.

Code:
globals
    real jumpHeight = 500.
    real totalJumpDuration = 0.
    real pollingInterval = 0.05
    real jumpSpeedMult = 2
endglobals

function Trig_Warbounce_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

function warStomp takes unit u returns nothing
    call print("Warstomp")
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", GetUnitLoc(u)))
endfunction

function getHeight takes real timeElapsed returns real elevation
    return Sin(timeElapsed * jumpSpeedMult)*jumpHeight
endfunction

function getRateOfChange takes real timeElapsed returns real roc
    return RAbsBJ((getHeight(timeElapsed) - getHeight(timeElapsed - pollingInterval))*(1/pollingInterval))
endfunction

function bounce takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local real airTime = TimerGetElapsed(t) + totalJumpDuration
    local real height = getHeight(airTime)
    local real roc = getRateOfChange(airTime)
    local unit caster = LoadUnitHandle(udg_Hashtable, GetHandleId(t), 0)
    if height < 0 then
        call SetUnitFlyHeight(caster, 0, roc*2)
        call warStomp(caster)
        //TODO: Check if caster has ability active and unit still has mana
        call PauseTimer(t)
        call DestroyTimer(t)
        set totalJumpDuration = 0
        call RemoveSavedHandle(udg_Hashtable, GetHandleId(t), 0)
    else
        call SetUnitFlyHeight(caster, height, roc)
        call print("Time elapsed: " + R2S(airTime) + " height: " + R2S(height) + " actual: " + R2S(GetUnitFlyHeight(caster)))
        set totalJumpDuration = totalJumpDuration + pollingInterval
    endif
    set caster = null
    set t = null
endfunction

function Trig_Warbounce_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit caster = GetTriggerUnit()
    call UnitRemoveBuffBJ('BEim', caster)
    //TODO: Set up mana drain effect?
    if UnitAddAbility(caster, 'Amrf') then
        call UnitRemoveAbility(caster, 'Amrf')
    endif
    call print("Warbounce")
    call warStomp(caster)
    call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 0, caster)
    call TimerStart(t, pollingInterval, true, function bounce)
    set caster = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Warbounce takes nothing returns nothing
    set gg_trg_Warbounce = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Warbounce, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Warbounce, function Trig_Warbounce_Conditions)
    call TriggerAddAction( gg_trg_Warbounce, function Trig_Warbounce_Actions )
endfunction

The 'print' function is defined in the map script and just displays the message with some formatting; you can treat it as "BJDebugMsg".
Thanks for your help.
 
Last edited:
Level 2
Joined
Jan 8, 2018
Messages
12
I guess that makes sense. I'd somehow assumed that the triggering unit would be globally available, but I can see why it wouldn't be. That'll probably fix both problems 1 and 2, considering they both rely on the caster variable. I guess I'll just stick 'caster' in a hashtable.
Thanks for your help.
As for the rate of change, I've updated it so that the caster's elevation rate changes smoothly and linearly from one polling interval to the next. Seems to be working.

EDIT: I also managed to fix problem 3. It turns out that, when you strip Immolation of all buffs and art and whatnot, it has a default buff which it reverts to. By applying the custom buff to the spell ("Stats - Buffs") it applies the custom buff INSTEAD of the immolation buff, rather than in addition to (as I had assumed).
I guess that's all my problems solved.
 
Last edited:
Status
Not open for further replies.
Top