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

Form change transfers abilities one way but not the other

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
I got a pretty simple transformation spell, and only one on the current hero. It's the hero's actual skill as well. Basically whenever the hero Transforms from form A to form B he'll change two of those skills based on his dummy skills.

Dummy Skill 1 is Hunt/Flurry, which in form A gives him hunt and in form B gives him flurry. The spell he learns is a dummy spell based on channel. The abilities are given and levled upon learning the skill.

DummySkill 2 follows the same principles as Dummy Skill 1. It's Rend/Drink.

Now the problem is, whenever he goes from form A to form B he doesn't transfer his skills. But when he goes back from form B to form A his skills transfer.

It use to work perfectly fine before I edited the code slightly, and I've been through it and can't see a problem.

Is my scripting off or is the problem with something in the object editor? Though I couldn't imagine what the problem in the object editor would be since it hasn't changed. The isbat skill is naturally on, and he's obviously learned the Dummy skills if they transfer proper.

tl;dr: Worked before, doesn't work now. WTF?

JASS:
scope BatForm initializer Init

globals
    private constant integer BatForm    = 'gbaf'
    private constant integer IsBat      = 'isba'
    private constant integer HuntFlurry = 'fbfl'
    private constant integer Flurry     = 'flur'
    private constant integer Hunt       = 'fibl'
    private constant integer RendDrink = 'frdr'
    private constant integer Rend     = 'rend'
    private constant integer Drink      = 'drin'
endglobals

private function Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local integer BFlvl = GetUnitAbilityLevel(c, BatForm)
    local integer HuntFlurrylvl = GetUnitAbilityLevel(c, HuntFlurry)
    local integer RendDrinklvl = GetUnitAbilityLevel(c, RendDrink)
    call TriggerSleepAction(0.27)
    if GetIssuedOrderId() == OrderId("bearform") then
        call SetUnitAbilityLevel(c, IsBat, BFlvl)
        if HuntFlurrylvl >= 1 then
            call UnitAddAbility(c, Flurry)
            call SetUnitAbilityLevel(c, Flurry, HuntFlurrylvl)
            call UnitRemoveAbility(c, Hunt)
        endif
        if RendDrinklvl >= 1 then
            call UnitAddAbility(c, Drink)
            call SetUnitAbilityLevel(c, Drink, RendDrinklvl)
            call UnitRemoveAbility(c, Rend)
        endif
    elseif GetIssuedOrderId() == OrderId("unbearform") then
        call SetUnitFlyHeight(c, 0.0, 0.0)
        if HuntFlurrylvl >= 1 then
            call UnitAddAbility(c, Hunt)
            call SetUnitAbilityLevel(c, Hunt, HuntFlurrylvl)
            call UnitRemoveAbility(c, Flurry)
        endif
        if RendDrinklvl >= 1 then
            call UnitAddAbility(c, Rend)
            call SetUnitAbilityLevel(c, Rend, RendDrinklvl)
            call UnitRemoveAbility(c, Drink)
        endif
    endif
 set c = null
endfunction

private function Conditions takes nothing returns boolean
        return GetUnitAbilityLevel(GetTriggerUnit(), BatForm) >= 1 and (GetIssuedOrderId() == OrderId("bearform") or GetIssuedOrderId() == OrderId("unbearform"))
endfunction

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

private function Init takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( t, function Conditions )
    call TriggerAddAction( t, function Actions )
endfunction

private function InitTrig_BatForm takes nothing returns nothing
endfunction

endscope
 
Level 5
Joined
Jan 5, 2008
Messages
145
What have you added since it last worked? Look through the things you've added since it last worked. its most likely happened when you added or changed something.
 
I got a pretty simple transformation spell, and only one on the current hero. It's the hero's actual skill as well. Basically whenever the hero Transforms from form A to form B he'll change two of those skills based on his dummy skills.

Dummy Skill 1 is Hunt/Flurry, which in form A gives him hunt and in form B gives him flurry. The spell he learns is a dummy spell based on channel. The abilities are given and levled upon learning the skill.

DummySkill 2 follows the same principles as Dummy Skill 1. It's Rend/Drink.

Now the problem is, whenever he goes from form A to form B he doesn't transfer his skills. But when he goes back from form B to form A his skills transfer.

It use to work perfectly fine before I edited the code slightly, and I've been through it and can't see a problem.

Is my scripting off or is the problem with something in the object editor? Though I couldn't imagine what the problem in the object editor would be since it hasn't changed. The isbat skill is naturally on, and he's obviously learned the Dummy skills if they transfer proper.

tl;dr: Worked before, doesn't work now. WTF?

JASS:
scope BatForm initializer Init

globals
    private constant integer BatForm    = 'gbaf'
    private constant integer IsBat      = 'isba'
    private constant integer HuntFlurry = 'fbfl'
    private constant integer Flurry     = 'flur'
    private constant integer Hunt       = 'fibl'
    private constant integer RendDrink = 'frdr'
    private constant integer Rend     = 'rend'
    private constant integer Drink      = 'drin'
endglobals

private function Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local integer BFlvl = GetUnitAbilityLevel(c, BatForm)
    local integer HuntFlurrylvl = GetUnitAbilityLevel(c, HuntFlurry)
    local integer RendDrinklvl = GetUnitAbilityLevel(c, RendDrink)
    call TriggerSleepAction(0.27)
    if GetIssuedOrderId() == OrderId("bearform") then
        call SetUnitAbilityLevel(c, IsBat, BFlvl)
        if HuntFlurrylvl >= 1 then
            call UnitAddAbility(c, Flurry)
            call SetUnitAbilityLevel(c, Flurry, HuntFlurrylvl)
            call UnitRemoveAbility(c, Hunt)
        endif
        if RendDrinklvl >= 1 then
            call UnitAddAbility(c, Drink)
            call SetUnitAbilityLevel(c, Drink, RendDrinklvl)
            call UnitRemoveAbility(c, Rend)
        endif
    elseif GetIssuedOrderId() == OrderId("unbearform") then
        call SetUnitFlyHeight(c, 0.0, 0.0)
        if HuntFlurrylvl >= 1 then
            call UnitAddAbility(c, Hunt)
            call SetUnitAbilityLevel(c, Hunt, HuntFlurrylvl)
            call UnitRemoveAbility(c, Flurry)
        endif
        if RendDrinklvl >= 1 then
            call UnitAddAbility(c, Rend)
            call SetUnitAbilityLevel(c, Rend, RendDrinklvl)
            call UnitRemoveAbility(c, Drink)
        endif
    endif
 set c = null
endfunction

private function Conditions takes nothing returns boolean
        return GetUnitAbilityLevel(GetTriggerUnit(), BatForm) >= 1 and (GetIssuedOrderId() == OrderId("bearform") or GetIssuedOrderId() == OrderId("unbearform"))
endfunction

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

private function Init takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( t, function Conditions )
    call TriggerAddAction( t, function Actions )
endfunction

private function InitTrig_BatForm takes nothing returns nothing
endfunction

endscope

both unit A and B need to have the dummy abilities in the object editor because basically only the level of the abilities that A and B share are saved and transferred not the ability itself...
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Oddly enough on heroes, when they transform the learned skills of the base are always transferred with them. A note, learned skills are always hero skills as only heroes can "Learn" skills. As well, stats don't transfer.

I've checked the skill rawcodes and tweaked around with the heroes. I've also tested to see what happens when I learn the skills in bat form, and they work just like they should. If you're in Bat Form and you learn Hunt/Flurry you get Flurry. Then you get Hunt when you transfer back.

But You don't get flurry back when you transform back.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
To transfer abilities between forms and upgrades you need to make the abilities permanent. Basically...

native UnitMakeAbilityPermanent takes unit whichUnit,boolean permanent,integer abilityId returns boolean

whichUnit is the unit whos ability you want permant, permanent is the boolean (permanent or not so it can be undone) and the abilityId is the raw data value of the ability you want to allow to transfer.
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Informative. I'll have to remember that incase I decide to do that for any spells.

Unfortunately, I'm assuming here, that what you're suggesting will allow me to take a skill on a current unit and make it transfer during metamorphosis. However, what I'm trying to do is remove the 2 skills on the first form and add 2 different skills on the second form that are the same level as the 2 on the first form. In other words:

Hero Form A - Consume, Rend, Hunt, Bat Form

vvvvv

Hero Form B - Consume, Drink, Flurry, Bat Form

Anyways, I'm having trouble with this still. What I don't understand is why this is only from normal form to bat form, and why it suddenly started happening.

OKAY sorry for the triple post but I feel this may be of importance.

I did fix it, and yes it was in the coding. For some reason the TriggerSleepAction wasn't registering properly. I had to remove it and place it after both if statements. It would only transfer to the first If statement.

Something similar also happened where I had 3 if statements in a method one right after the other. The first one I insterted would work fine but the two after it didn't work at all no matter how hard I tried. I ended up combining them into a single if statement and found a pretty good work around, but still it was odd.

I dunno, could someone explain to me what this is about?
I'll see if I can't dredge up the old code.
 
Last edited by a moderator:
Status
Not open for further replies.
Top