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

How to change range on units. (A tutorial on replacing units.)

Level 3
Joined
Oct 17, 2007
Messages
22
I've been searching the forums and a lot of posts from people are about changing the attack range of a unit in-game. This is not something that can be done with a simple trigger or ability. You cannot do it using the acquisition range trigger, you cannot do it using upgrades (to a certain extent), and you cannot do it with searing arrows, cold arrows, etc., without having to manually click the button each time.

The way you can do it, however, is by replacing your in-game units with units that appear to be the same unit, except they wield a different weapon.

This may seem like a bit of work, but it really is not that much time compared to the time you should have already spent on terraining your map and other such details.

Step one.

The first thing you must do is create a unit. The unit I will create will be called "Marine".

The second thing you must do is create a second unit. This unit will be the mock unit for the item you are going to pick up with the unit "Marine". The item I want to pick up is a sniper rifle. The unit will thusly be called "Marine Marksman".

Certaintly, that was easy.


Step two.

Now, you must create the item you will be picking up. When creating this item, select a simple item that has only one effect, such as the first item listed, Claws of attack (+15). I will name my item "Sniper Rifle".

Step three.

Now comes the fun part, using triggers. It's all done in GUI, so do not worry, it truly is easy. For your first trigger (I will explain what they do after I list them), place this for you Event, Conditions, and Actions:

  • Sniper Rifle Pickup
    • Events
      • Unit - A unit owned by Player 1 (Red) Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Not equal to Marine Marksman
      • (Item-type of (Item being manipulated)) Equal to Sniper Rifle
    • Actions
      • Wait 0.01 game-time seconds
      • Unit - Replace (Hero manipulating item) with a Marine Marksman using The old unit's relative life and mana
      • Selection - Select (Last replaced unit) for Player 1 (Red)
The event is pretty obvious. When a unit owned by player one picks up ANY item, run this event. The conditions make sure that the Marine Marksman is not the one picking up the item (he is already a marksman, he doesn't transform when he picks it up) and the second makes sure that it is the Sniper Rifle (you don't want to pick up a shotgun and be turned into a Marksman). The wait time is so that the item doesn't think it is being dropped by both the Marine and Marksman at the same time (crashes game). The unit replace just swaps the unit. The selection just makes it so that it seems as though the units never swapped places in the first place. Seamless transition.

The second trigger is as follows:

  • Sniper Rifle Drop
    • Events
      • Unit - A unit owned by Player 1 (Red) Loses an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Not equal to Marine
      • (Item-type of (Item being manipulated)) Equal to Sniper Rifle
    • Actions
      • Wait 0.01 game-time seconds
      • Unit - Replace (Hero manipulating item) with a Marine using The old unit's relative life and mana
      • Selection - Select (Last replaced unit) for Player 1 (Red)
The basically does the opposite of the other trigger. When the unit drops ANY item, this trigger activates. You make sure he is not a marine (so that game doesn't crash again, thinking the marine and marksman dropped the rifle) and makes sure it's the sniper rifle (you don't want shotgunner dropping something and turning him into marine, but still holding onto shotgun). The wait time in actions makes it so the game doesn't crash (again, the game would think the two units both drop the same item at the same time), the next action replaces the units, and the next makes the transition so it appears as though the unit was upgraded, and not replaced.

The Final Step.

Go in game and place the item you chose on the ground. Place the unit you want, like my "Marine" unit, next to the item. Test the map, pick-up the item, and like magic, the unit changes. Drop the item, and he turns back.

:infl_thumbs_up:
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
It's okay, it could use polish though.

  • Make use of the [trigger][/trigger] tags.
  • Maybe use red or green instead of blue? Blue is a bit harder to see than the other two.
  • You may want to edit the intro, particularly, to more of an intro, and less of a story (It makes it sound more effective).
 
Top