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

Morphing Units

Status
Not open for further replies.
Level 3
Joined
Jul 12, 2014
Messages
34
Hello there, I’m trying to create a system in my map where a unit can morph into various other units, which can then morph back into the initial unit. But have the resources spent to morph into the unit initially be refunded in full when they do.

so for instance unit 1 morphs into unit 2 for the price of 100 gold and 100 wood. Unit 2 can press a button to morph back into unit 1 and the 100g/w would be refunded in its entirety. Unit 1 would be able to morph into about 6 or 7 different units. How would I go about setting something like this up? Assuming triggering would be required for something like this, what would it look like in Jass?
 
Level 21
Joined
Dec 4, 2007
Messages
1,480
You might get away with manipulating the Destroyer form ability of the undead.
It automatically refunds too.
 
Level 3
Joined
Jul 12, 2014
Messages
34
Tried using that approach just now, so unit 1 morphs into the unit for 75g, and when the unit morphs back to unit 1 (worth 0g currently), nothing is given back. Might not have made it correctly in the obj editor but i suppose i could make unit 1 worth -75g to create, so it'd technically refund it, but the other units it can morph into aren't worth 75g, did I make it wrong or would this approach not work for my purposes?
 
Level 21
Joined
Dec 4, 2007
Messages
1,480
Examine the values of the Obsidian Statue (200 gold) and Destroyer (300 gold) - this means morphing from statue to destroyer costs 100 g (the difference).
Thus morphing back refunds 100g and even the food cost (statue 3, destroyer 5).
 
Level 3
Joined
Jul 12, 2014
Messages
34
I'm not sure I follow, looking in the obj editor, it says Destroyers cost 100g meanwhile obsid statues do indeed cost 200. From what I can tell with regards to the destroyer form ability the amount of money it costs is based on the unit thats being transformed into's cost. so the cost for my primordial unit to turn into it is 75, but when i try to use a second destroyer form ability to turn the 2nd unit (the one that costs 75) into the first unit (which costs 0) I don't regain any of the resources spent initially
.
upload_2021-1-25_14-18-37.png
 
Level 21
Joined
Dec 4, 2007
Messages
1,480
Check Scenario - Map Options - Options - Game Data Set

I think you are on Custom (1.01) - turn that to Melee (Latest Patch).
 
Level 3
Joined
Jul 12, 2014
Messages
34
seems like I was on default, presumably custom. sure enough i toggled it and it seems to have fixed it, thanks for the help there buddy and sorry bout the hassle, didn't even know that was a thing
 
Level 3
Joined
Jul 12, 2014
Messages
34
Apologies for the necropost, but after more testing it seems like the "primordial unit" (the one which can morph into 6 different things) just picks one of the options at random, regardless of which button i click or hotkey i press. I based all 6 of the morph spells on the destroyer form ability and they each evolve into something different. What did I do wrong?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
A unit can't have multiple copies of the same active ability without this happening, this is due to the order id of the ability. You can see this value on the ability under the Order String field (order string/id, same thing).

For example, the Shockwave ability uses the order id "shockwave".

So when you order a unit to cast Shockwave the unit is actually issued the "shockwave" order, which tells the unit to cast it's ability with the "shockwave" order id.

If the unit has more than 1 ability with the "shockwave" order id, it chooses one of those abilities at random to cast (although I think it will pick the same ability again and again as long as it remains off cooldown).

A lot of people get fooled at this point and think, "okay, so all I have to do is change the order id of Shockwave", unfortunately, this doesn't work. Even though you can literally edit the Order Id (Order String) in the Object Editor to something else, it won't actually work. It's really just a stupid oversight on Blizzards part to even allow one to edit it in the first place since it doesn't work.

Luckily, you can use the Channel ability, a Hero ability found in the Neutral Hostile category. This ability has a special field called "Base Order Id". This allows you to assign the ability any of the Order Ids that exist in the game, meaning if you give a unit 6 abilities based on Channel, and each ability has it's own unique Base Order Id, they will all work properly.

Channel is by default meant to be a channeling ability, so you'll need to modify it to make it work like a non-channeling ability. It has a lot more control than a standard ability because it's meant to be used with triggers, so:
1) Set it's Follow Through Time to 0.00 seconds. (how long it channels for)
2) Set Disable Other Abilities to False. (whether or not it pauses the unit while channeling)
3) Set it's Options to Visible. (whether you can see the ability in the first place)
4) Set it's Targeting Options to Instant. (no targets required to cast)

Now from there you would give your unit all 6 of these new Channel abilities. You would design them to LOOK like the Destroyer Form ability, when in reality they don't actually do anything.

The plan is to trigger it so that when your unit casts one of these Channel abilities, the unit is given the REAL Destroyer Form ability that it was originally supposed to cast, and is ordered to cast it:

Events:
A unit begins casting an ability
Conditions:
Ability being cast equal to Grunt Morph (Channel)
Actions:
Add Grunt Morph (Destroyer Form) to Triggering unit
Order Triggering unit to Obsidian Statue - Destroyer Form (this is an Order with no Target)

So Grunt Morph (Channel) is your Channel ability. Grunt Morph (Destroyer Form) is the actual Destroyer Form ability that will transform your unit into a Grunt (just an example).
 
Last edited:
Level 21
Joined
Dec 4, 2007
Messages
1,480
Right i forgot about the issue of abilities with the same order id overriding each other...

I think you'll have to make use of all the different transformation abilities:

  1. Destroyer Form - of the the Destroyer
  2. Stone Form - of the Gargoyle
  3. Bear Form - of the Druid of the claw
  4. Storm Crow Form - of the Druid of the talon
  5. Ethereal Form - of the Spirit Walker
  6. Submerge - of the Myrmidon/Royal Guard/Snap Dragon (all sharing the same order id, so choose only 1)
  7. Metamorphosis - of the Demon Hunter
I'm not sure Metamorphosis works exactly the same like the former 6.

You could also trigger the whole ordeal, like Uncle has shown.
 
Level 3
Joined
Jul 12, 2014
Messages
34
Alright cool stuff, it worked, thanks alot guys. That said, is there any way to bring back the gold/wood cost associated with using the ability? Like how Destroyer form has? Not necessary as i can just put that stuff in the tooltip, but would be a nice quality of life thing at least
 
Level 3
Joined
Jul 12, 2014
Messages
34
tried out his channel method, checking the channel thing and im not seeing where i'd put the "requires payment" flag at, also, it seems like while it does deduct funds properly when my units do a channel transform, it wont prevent the ability from being cast, so even if i dont have enough money to cover the cost it just happens anyways
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
Requires Payment is in the Morphing Flags, it's one of the checkboxes.

You should use the Charge Gold and Lumber ability instead of Channel. This ability allows you to add a gold/lumber cost as well as being able to change the Base Order Id field like channel.

If you do this then you'll want to remove the Payment from the Destroyer Form ability so that you don't pay twice.

You may also want to change the Event of your trigger to: A unit starts the effect of an ability.

This is because Begins casting happens before the costs are paid.
 
Status
Not open for further replies.
Top