• 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.

[Spell] Adding and removing the Build(AHbu) Ability

Status
Not open for further replies.
Level 1
Joined
May 15, 2011
Messages
3
Hi!

I wonder if it's possible to do what it says in the title.
I'm creating a map where I want a single unit to be able to change into another unit with the build ability, and when the unit changes back it loses the build ability.
With all the alternatives for switching unittype(metamorphosis, bear form, etc..) the unit retains the build ability in both forms.
My current solution is to just remove and create the units with an ability but this solution isn't working with the rest of my code due to trigger events and so on.
It seems to be possible to remove the ability but not adding it.

Has anyone any idea on how to solve this?



Thanks
Dau
 
Level 3
Joined
Aug 18, 2013
Messages
49
you can do it without trigger though
Without Triggers:
1. Create 2 units (1 of them is categorized as special).
2. give the second unit build ability (categorized as special).
3. but don't give it to first unit.
4. change your ability (metamorphosis, bear form, etc) normal form to the first unit, alternate form to second unit.

With Triggers:
  • Events
    • Unit is issued order with no target
  • Conditions
  • Actions
    • If (Conditions)
      • Issued Order equal to unBear Form
    • then (Actions)
      • Unit - Remove Build (Human) from Your Unit
    • Else (Actions)
      • If(Conditions)
        • Issued Order equal to Bear Form
      • then (Actions)
        • Unit - Add Build (Human) to YourUnit
      • Else (Actions)

the trigger is not tested yet.. but the first method is working to me
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
you can do it without trigger though
1. Create 2 units (1 of them is categorized as special).
2. give the second unit build ability (categorized as special).
3. but don't give it to first unit.
4. change your ability (metamorphosis, bear form, etc) normal form to the first unit, alternate form to second unit.

triggers:
  • Events
    • Unit is issued order with no target
  • Conditions
  • Actions
    • If (Conditions)
      • Issued Order equal to unBear Form
    • then (Actions)
      • Unit - Remove Build (Human) from Your Unit
    • Else (Actions)
      • If(Conditions)
        • Issued Order equal to Bear Form
      • then (Actions)
        • Unit - Add Build (Human) to YourUnit
      • Else (Actions)

the trigger is not tested yet.. but the first method is working to me

You said without triggers but I see there are triggers XD
Also Does my method work or not?
 
Level 3
Joined
Aug 18, 2013
Messages
49
i give him an option

the first one is without triggers
the next one is with triggers
 
Level 1
Joined
May 15, 2011
Messages
3
The following call does not work
JASS:
call UnitAddAbility(unit 'AHbu')

I want my unit to be able to change unittype (e.g bearform) with a unit that can build structures (i.e have a list of buildings in the "Structures Built" datafield in the object editor).
The issue being that once the unit without the build ability has morphed into a unit with the build ability, both unit permanently gains the build ability.
And if you remove the ability with
JASS:
call UnitRemoveAbility( unit, 'AHbu')
both unit loses the ability permanently.
 
Level 1
Joined
May 15, 2011
Messages
3
Posting the solution here, credit to Fledermaus
JASS:
scope MorphSpell initializer Init

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Abrf' and GetUnitTypeId(GetTriggerUnit()) == 'hkni'
endfunction

private function Actions takes nothing returns nothing
    call UnitRemoveAbility(GetTriggerUnit(), 'AHbu')
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    set gg_trg_MorphSpell = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_MorphSpell, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(gg_trg_MorphSpell, Condition(function Conditions))
    call TriggerAddAction(gg_trg_MorphSpell, function Actions)
endfunction

endscope
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Corrected :
JASS:
scope MorphSpell initializer Init

private function Cond takes nothing returns boolean
    if GetSpellAbilityId() == 'Abrf' and GetUnitTypeId(GetTriggerUnit()) == 'hkni' then
        call UnitRemoveAbility(GetTriggerUnit(), 'AHbu')
    endif
    return false
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)
    call TriggerAddCondition(t, Condition(function Cond))
    set t = null
endfunction
endscope
 
Level 21
Joined
Mar 2, 2010
Messages
3,069
when a unit metamorph into another unit with an empty build menu the build menu still appears but it is empty. it is good choice if you dont care if the build button is present. another solution is to replace the casting unit with another unit through a trigger. you could for example use destroyer form. just check this map.
 

Attachments

  • unit replacement example.w3x
    16.9 KB · Views: 55
Status
Not open for further replies.
Top