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

[JASS] Changing a units attack in-game

Status
Not open for further replies.
Level 24
Joined
Feb 28, 2007
Messages
3,479
Hello fellas.

I need your help with creating a piece of JASS code which should, ingame change a units attack, like disable Attack 1 and enable Attack 2. For a more brief description: "The hero attacks with a sword, but has an ability called Equip Shuriken, he has two attacks, Attack 1, normal meele range etc. Attack 2, ranged attack that can target air and has a shuriken projectile. The Equip Shuriken should enable attack two and disable attack 1, and then when Equip Shuriken is cast, it should be changed into Equip Sword which works like Equip Shuriken but equips the sword."

Thanks in advance.
 
Well, there is nothing you can do with JASS to help you.
You can, however, use a morph ability. The morphed hero is just like the normal one, but his attack is different.
Few morphing abilities that may help are:
- Metamorphosis (Illidan lv 6)
- Goblin Rage
- Statue transformation

This is the answer for your trouble, and no triggers are needed.
Hope it helps =D
 
Last edited by a moderator:
Level 12
Joined
Apr 27, 2008
Messages
1,228
That is kinda messy.
First thing to my mind are upgrades.
Another way would be orb skills and/or silence(I have not studied those abilities in detail, but they will do the job).
 
Level 24
Joined
Feb 28, 2007
Messages
3,479
@Flame,Phoenix, Metamorphosis and the Goblin Rage lasts only for a certain amount of time and this should be permanent until you switch back to sword. The statue transformation, well that'll be real messy since when you switch into it you will lose your current level etc. Like if you level in sword form, change to ranged form you will not gain the level you got while in other form etc. Same with skills you spec.

@spiwn, the orb skills should be those used by Orb of Fire etc. I figure. However the problem is that those only allow ranged attack on flying and not on ground units. What do you mean by silence ?
 
Silence allows and disallows specific types of attacks, but they only last for an amount of time as well.

Using JASS; there is another possible solution.
1 - the hero uses the ability
2 - use a special effect on him
3 - remove that hero
4 - create a new hero with ranged attack
5 - set his abilities to the normal levels
6 - set the new unit's life equal to the old unit's life
7 - you are done

Pros:
- easy and intuitive to use, people wont see a difference

Cons:
- call RemoveUnit() has some issues and is currently banned on the new systems
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Orb abilities turn on attack 2 of the heroes.
Silence can be used to disable the other.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
As I said, haven't really examined those abilities.
To lazy to do it now, but rather simple.
With a trigger you can add an item ability based on some orb/disabled spellbook with a unit ability based on the item ability of some orb(the ability should enable attack 1 or 2) then make a dummy cast an ability based on silence/drunken haze disabling the other attack.
This is just one way of doing this.
As I said upgrades are also an option.
Maybe making the unit with both attacks enabled and then disabling one of them with silence/drunken haze.
About length of silence, experiment - try it with 0 duration. If it is infinite then ok, if it is not just use some really big value(shift + click).
 
Level 3
Joined
May 12, 2006
Messages
31
@Flame,Phoenix, Metamorphosis and the Goblin Rage lasts only for a certain amount of time and this should be permanent until you switch back to sword. The statue transformation, well that'll be real messy since when you switch into it you will lose your current level etc. Like if you level in sword form, change to ranged form you will not gain the level you got while in other form etc. Same with skills you spec.

@spiwn, the orb skills should be those used by Orb of Fire etc. I figure. However the problem is that those only allow ranged attack on flying and not on ground units. What do you mean by silence ?

If you change the time 0, then it will be permanent, and can be switched to the original unit. If you check in the"permanent" flag, you cant turn the metamorphosis back.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
In addition to morpging solutions there's also the mountain giant's ability to pick up a tree, which changes your attack type for the exact same unit. But it must target a tree...

I've used this in a very old noob map where the archer had to chop down a tree to get 100 arrows.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Thinking about it more I would choose morphing(well now, this depends on how many units are going to have this ability).
(the other stuff was just the first thing that came to my mind(as I said ) )
I suggest using Bear Form(no time bar) as base skill.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Yeah, but what if the ability is gained by an item( "Shuriken" ) and every hero in the game can have it ...
 
Status
Not open for further replies.
Top