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

Finding the followed unit

Status
Not open for further replies.
Level 4
Joined
Aug 9, 2008
Messages
67
Hi everybody

I am busy trying to make a map similar in a way to worm wars and I would like to know if it it possible to find which unit a specific unit is following, in other words, the followed? And if so how can it be done?
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
There is no event like that. If you want to register a created unit, it would respond to the event "Unit enters playable map area", and that unit would be triggering unit, not last created unit since that could be bugging the game.

Im doing a trigger for this. But right know I cant continue since we got visits downstairs. If anyone wants to do a try, go ahead though :]
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Wellz, I made a sample which is working, but has one issue. When using "follow" the segments are not instantly moving when another segment is. I don't know how to do that though, but the rest is all good.

3 things to mention...
:Crypt Lord and Carrion Beetles is just the "head" and the "segments". Change this to anything you want.
:The first trigger is ran on map initlialization or before starting to move and such, for the first time.
:The second trigger is fireing after killing a sheep in this example. Change the event if you want that, but dont forget to change "owner of killing unit" to something else in that case.

  • Init WormStuff
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set tempgroup = (Units of type Crypt Lord)
      • Unit Group - Pick every unit in tempgroup and do (Actions)
        • Loop - Actions
          • -------- You must add the "headunit" on your snake in the first array --------
          • -------- we are only using one segmentunit array to make it easier. Every player starts their "head" at (playerindex*100)-99 --------
          • Set WormPart[(((Player number of (Owner of (Picked unit))) x 100) - 99)] = (Picked unit)
          • -------- no segments in the beginning, thus set it to 0 --------
          • Set CountSegment[(Player number of (Owner of (Picked unit)))] = 0
      • -------- Leak cleanage --------
      • Custom script: call DestroyGroup( udg_tempgroup )
  • New Segments
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Sheep
    • Actions
      • -------- Defines the owner of the killing unit's player index --------
      • Set player_index = (Player number of (Owner of (Killing unit)))
      • -------- Defines the first index of the players worm --------
      • Set starting_index = ((player_index x 100) - 99)
      • -------- Store the last wormsegment's point and create the new segment's spawn point --------
      • Set temppoint[0] = (Position of WormPart[(starting_index + CountSegment[player_index])])
      • Set temppoint[1] = (temppoint[0] offset by 128.00 towards (180.00 - (Facing of WormPart[(starting_index + CountSegment[player_index])])) degrees)
      • -------- Create the new worm segment --------
      • Unit - Create 1 Carrion Beetle (Level 1) for (Player(player_index)) at temppoint[1] facing (Facing of WormPart[(starting_index + CountSegment[player_index])]) degrees
      • -------- Order it to follow the previous wormsegment --------
      • Unit - Order (Last created unit) to Follow WormPart[(starting_index + CountSegment[player_index])]
      • -------- Increase Segment Index --------
      • Set CountSegment[player_index] = (CountSegment[player_index] + 1)
      • -------- Store the last created segment --------
      • Set WormPart[(starting_index + CountSegment[player_index])] = (Last created unit)
      • -------- Leak cleanage --------
      • Custom script: call RemoveLocation( udg_temppoint[0] )
      • Custom script: call RemoveLocation( udg_temppoint[1] )
~Eccho~
 
Level 4
Joined
Aug 9, 2008
Messages
67
Thanks for that guys but thanks to my bad explaining you have helped me with the wrong problem.

The thing is that the units attack passively (like in tank wars) but only the last one must be able to die. The simplest way to do this (as far as I know) is to make the unit invulnerable when the next segment spawns.

The problem then arises to make the unit vulnerable again when the last segment dies so that it, in turn can die.

Make sense?

P.S I apologize any inconvenience caused
 
Level 13
Joined
Jul 3, 2008
Messages
1,098
if i understand you, you want to make all worms invulnerable instead of last one. and when the last one dies you want to make in that time last one vulnerable.


New Segments

Events

Unit - A unit Dies

Conditions

(Unit-type of (Triggering unit)) Equal to Sheep

Actions

-------- Defines the owner of the killing unit's player index --------
Set player_index = (Player number of (Owner of (Killing unit)))
-------- Defines the first index of the players worm --------
Set starting_index = ((player_index x 100) - 99)
-------- Store the last wormsegment's point and create the new segment's spawn point --------
Set temppoint[0] = (Position of WormPart[(starting_index + CountSegment[player_index])])
Set temppoint[1] = (temppoint[0] offset by 128.00 towards (180.00 - (Facing of WormPart[(starting_index + CountSegment[player_index])])) degrees)
-------- Create the new worm segment --------
Make vulnerablebeetle invulnerable
set variable invulnerablebeetle=vulnerablebeetle
Unit - Create 1 Carrion Beetle (Level 1) for (Player(player_index)) at temppoint[1] facing (Facing of WormPart[(starting_index + CountSegment[player_index])]) degrees
set variable vulnerablebeetle=last created unit

-------- Order it to follow the previous wormsegment --------
Unit - Order (Last created unit) to Follow WormPart[(starting_index + CountSegment[player_index])]
-------- Increase Segment Index --------
Set CountSegment[player_index] = (CountSegment[player_index] + 1)
-------- Store the last created segment --------
Set WormPart[(starting_index + CountSegment[player_index])] = (Last created unit)
-------- Leak cleanage --------
Custom script: call RemoveLocation( udg_temppoint[0] )
Custom script: call RemoveLocation( udg_temppoint[1] )

and then
event:
unit dies
condition:
dying unit equal to vulnerablebeetle
action:
set variable vulnerablebeetle=invulnerablebeetle


i have used this trigger to show you where you must give these things
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
I think locust is an appropriate way as well since you cant select the middle segments that way (they are not targetable anyways). But yea invulnerable is ok too I guess

Well, then, you could do that, when a new segment is created, store him in a unit array (let say; LastSegment ) with the index responding to the correct player number of the killing unit. But before that, remove the locust/invu ability from the current last segment. Then, simply "Set LastSegment[player number of owner of killing unit] = Last created unit". So by that, you could keep track of the right final segment.

Edit: this is in the same path as numerion suggests. However it has to be a unit array (or two), since it otherwise would override any worm's last segment with their last one.
 
Status
Not open for further replies.
Top