• 🏆 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!

[JASS] Transferring abilities during transformation

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
Alright so I have a spell on a hero based off bearform.

It's a hero transformation, so the spells the hero learns stay with him.

The thing is, he has 2 dummy hero spells which give him abilities. If he is in Non-Form, he will be given SpellA, but when he changes to Form he is given SpellB and SpellA is removed. Vice versa on change back. The abilities he's given also level when he learns the dummy spells, and are non-hero abilities.

The problem is I need to give him the spells after he transforms, and I don't know how to detect the time after he transforms and changes back.

But for your amusement, here is the current setup I have for the trigger. It's highly incomplete as I'm on crossroads what to do with it :\

JASS:
function BatForm_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    if GetIssuedOrderId() == OrderId("bearform") then
        //If the order is to transform the unit from normal form into a bat
        call SetUnitAbilityLevel(caster, 'isba', GetUnitAbilityLevel(caster, 'gbaf'))
        //isba is the spell IsBat, and is a passive, invisible stat boost that grants +STR
        // and is used to see if the unit has the spell, meaning it's a bat.
        if GetUnitAbilityLevel(caster, 'fbfl') >= 1 then
            //Checks to see if we've learned the "Find Blood/Flurry" dummy hero ability.
            call UnitAddAbility(caster, 'flur')
            //We add the ability Flurry for his bat form, then level it up.
            call SetUnitAbilityLevel(caster, 'flur', GetUnitAbilityLevel(caster, 'fbfl'))
            call UnitRemoveAbility(caster, 'fibl')
            //We now remove Find Blood from the hero as it is only for regular form.
        endif
        //rinse, repeat
        if GetUnitAbilityLevel(caster, 'frdr') >= 1 then
            call UnitAddAbility(caster, 'drin')
            call SetUnitAbilityLevel(caster, 'drin', GetUnitAbilityLevel(caster, 'frdr'))
            call UnitRemoveAbility(caster, 'fren')
        endif
    else
        //when turning back we need to make the gangrel not up in the air, unlike his bat counterpart
        call SetUnitFlyHeight(caster, 0.0, 0.0)
        if GetUnitAbilityLevel(caster, 'fbfl') >= 1 then
        //repeat steps
            call UnitAddAbility(caster, 'fibl')
            call SetUnitAbilityLevel(caster, 'fibl', GetUnitAbilityLevel(caster, 'fbfl'))
            call UnitRemoveAbility(caster, 'flur')
        endif
        if GetUnitAbilityLevel(caster, 'frdr') >= 1 then
            call UnitAddAbility(caster, 'fren')
            call SetUnitAbilityLevel(caster, 'fren', GetUnitAbilityLevel(caster, 'fbfl'))
            call UnitRemoveAbility(caster, 'drin')
        endif
    endif
 set caster = null
endfunction

function BatForm_Conditions takes nothing returns boolean
    //Check to see if the unit is using bearform spell in the form of a Orderstring, so we can call up orderstrings
        return GetIssuedOrderId() == OrderId('bearform') or GetIssuedOrderId() == OrderId('unbearform')
endfunction

//===========================================================================
function InitTrig_BatForm takes nothing returns nothing
 local trigger BatForm = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( BatForm, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( BatForm, function BatForm_Conditions )
    call TriggerAddAction( BatForm, function BatForm_Actions )
 set BatForm = null
endfunction
 
Last edited:
Level 13
Joined
Jul 26, 2008
Messages
1,009
The periodic seems like it could consume an unnecessary amount of processing.

I'll see if detecting the orderstring in the conditions works as you've suggested. However I have a feeling that this will cause the actions to run before the transformation instead of after. One wayt to find out.

Nope, didn't work :\ There's gotta be a method to do this. TKoK has done it in their older maps :X
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
You're registering the event EVENT_PLAYER_UNIT_ISSUED_ORDER but your conditions are only prepared to handle values returned by the EVENT_PLAYER_UNIT_SPELL_FINISH event. When a unit is issued an order, the "actions" function won't run because GetSpellAbilityId( ) will return null.
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Right now I'm really not worried about that. I'll likely fix or remove it once I figure out how to apply the abilities and changes when the hero has changed form.

I was doing that in the middle of figuring out how to determine if the unit had become his alternate form after using the ability. That's why it's like that, and I'm well aware it's incorrect.
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Yeah.

You cannot give abilities to a unit until after it transforms, otherwise the abilities are removed. Unfortunately spell effect registers the event just before the transformation, as does a few other of the abilities.

I'm thinking of just using a wait, but I'm uncertain of what will happen, and what bugs may arise from using a wait timer with little leeway for it being innaccurate.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I would do it the most accurate and invisible way possible. Use a timer that expires the exact duration of the transformation after the ability starts effect, and then add/remove the abilities.

When I first read the thread I tested out some of the responses that Metamorphosis and Bear Form gave (Metamorphosis crashed Warcraft) but Bear Form seemed to function properly. If I remember correctly, the duration of the transformation dictated the time between the unit actually "casting" the ability and the unit completing its transformation.
 
Status
Not open for further replies.
Top