• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

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

Status
Not open for further replies.

dauid

D

dauid

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
 
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
 
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?
 
i give him an option

the first one is without triggers
the next one is with triggers
 
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.
 
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
 
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
 
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

You're saying Remove Ability works?

Then what am I doing wrong?

  • Events
    • Unit - A unit Finishes casting an ability
  • Conditions
    • (Ability being cast) Equal to (==) Morph
  • Actions
    • Unit - Remove Build (Human) from (Casting unit)
It does work for different actions. Also tried "Triggering unit".
 
Thought it was better than creating a new thread...

JASS:
Custom script:   call UnitRemoveAbility(GetSpellAbilityUnit(), 'AHbu')

Doesn't work. Maybe it's not possible on worker units? I also can't add build abilities from other races.

Nevermind though, don't need it anymore.
 
Status
Not open for further replies.
Back
Top