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

[Solved] Unit replacing

Status
Not open for further replies.
Level 1
Joined
Jan 29, 2013
Messages
3
So im pretty new to triggers and still pretty bad at it. I've made a trigger that turns one of the selectable heroes into a werewolf hero at a specific time of day. I want the werewolf heroes abilities to rank up alongside the normal heroes abilities (e.g i rank up normal heroes' Summon Dire Wolves ability to 2, when he turns into werewolf, the werewolfs ability Hurl Boulder is also rank 2). It fails to learn and set the ability level to the right value, it also fails to set the available skill points to the amount that my normal hero had available.

This is what my trigger looks like:
upload_2016-8-16_0-55-0.png

The other If (all conditions are true) triggers are the same template, but for different skills.
 
Level 4
Joined
Jul 26, 2016
Messages
88
The first problem I can spot out here is that in

Set Level of Hurl Boulder

Picked unit doesn't reference any unit.

There is no "Picked unit" because "picked unit" only refers to units picked while INSIDE the pick unit block.

What you want instead is: Pick Units in Unit Group and do Multiple Actions

and nest both of the actions (the replacement of the unit and the ability manipulation of the unit) INSIDE that pick units and do multiple actions block.

Also, you do not need "Do nothing"

Also your last line: there is also no Picked unit here. The moment you exit the pick units block, picked unit references NO ONE.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
!!!Wall of text warning!!!

First of all, you dont want to use "Unit - Replace Unit".
Secondly, you should find a way to index all the Vrykul Warlords.
Thirdly, never use a one liner like that. I mean, it is horrible to read the unit group thing. You should use "and do multiple actions".
Fourthly, picked unit is also noone as long as you are not in a unit group (or would be the last unit that you iterated over, which was replaced so removed from the game).
And last but not least, "Do nothing" doesnt do nothing. If you want it for readability, you can use a comment stating " --- Do nothing --- " or you can leave it empty.
For something nice, lets talk about Engineering Upgrade.

So now lets get on with that.
1, Replace Unit:
Replace unit removed the original unit from the game and creates a new unit with the same position and % health (if set to) as the old unit.
This function breaks many triggers because all the unit variables that were pointing to that hero dont have anything to point to any more.
Next to which, it also doesnt really copy all stuff from the old unit.
A better way to transform a unit is with an inversed bear form transformation.
This thread explains in great detail how it works and what it does and how you activate it.

2, Indexing Vrykul Warlords:
Picking all units in the entire map and checking if they are Vrykul Warlords is not really nice to do... so instead you should have a unit array and an integer to know the amount and loop over that array.
So VrykulWarlords[0] = Vrykul Warlord
VrykulWarlords[1] = Vrykul Warlord
VrykulWarlords[2] = No unit
VrykulWarlordsLength = 2
would be the values if there are 2 Vrykul Warlords on the map, then you can loop from 0 to VrykulWarlordsLength -1 (I think -1 because of how GUI works) and then apply your effects to those units instead.
Every time a Vrykul Warlord enters the map (best done using a unit indexer) you put it in the VrykulWarlords[VrykulWarlodsLength] and you increase the VrykulWarlodsLength.

3, One liners:
They look amazing, until you want to read them.
Always avoid "Pick all units in group and do action", "Loop from X to Y and do action", "Pick all players in force and do action", "if <condition> then <action> else <action>" etc.
ALWAYS (except if it really looks better) use the multi lined version.
Even for groups with a filter (the matching unit part), you could put that as an if/then/else inside the loop. If you loop over the group already, you should put it in the loop, otherwise you also end up doing double work.

4, Picked Unit outside of group loop.
Picked unit refers to the unit currently being picked... in a group loop... which you dont use. To amplify number 1, it points to the Vrykul Warlord before it was replaced, but it got removed so you cant really use it any more.

5, Do nothing.
Do nothing doesnt actually do nothing. It runs a function that has no actions.
So it still consumes processing time (yea I know it is not much, but you basically throw one dollar to the trashcan... every time).

6, Engineering Upgrade.
Engineering Upgrade (the ability that increases the stats of the Goblin... tank guy's other abilities) can, in essence, replace abilities while keeping their stats and even things like their current cooldown if they were on cooldown.
This ability can also switch hero ablities, which is the reason why it is so famous.
You should definately try out how it works or search some threads about it.

There is one thing that will bother you, which is that it shows an icon, but if you put it in a spellbook and give the spellbook instead of the actual ability, it will show the spellbook on the UI. But spellbooks can be hidden (while still having the passive effects of the abilities they have) by disabling the spellbook for the players (preferably all players) so you should have a trigger at map init that loops through all players and disables all those spellbooks that you use.

I hope this will help you.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Wait... you are going to tell me that you managed to read my wall of text, find out how those things work, implement them in your map, add them to your unit, create the triggers, test the whole thing for bugs and come back to write you did that in 4 minutes - the time between you coming here and me posting here?

No way!
 
Level 1
Joined
Jan 29, 2013
Messages
3
Nah, i did read what you wrote, but i followed Bitchmoons advice instead since what you said seemed a little too complicated for me yet.
 
Status
Not open for further replies.
Top