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

Distance between 2 Units {a specific unit and another random unit owned by a player}

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

1) First - ofc I know the search functions - but dont find anything about my problem.

I want do the following: I created 1 Unit and place it on the map. If you klick this Unit - actions happend. But this action should only happend, if the distance between the Unit (Selected Unit) and the Owner of the Unit who select are lower then xxx.

Problem is - how I call the Unit who select the (selected Unit)?

- Edit: I got more controllable Units - so I dont want create a variable for each Unit - and get the distance between selected Unit and variable - would take to long)

(I'm not rly good with Jass - but if it is possible with Jass - post it^^)
 
Level 11
Joined
Mar 31, 2009
Messages
732
I've got a system kind of like this on my map. I don't remember the functions I used though.
Take a look (requires NewGen): http://www.hiveworkshop.com/forums/map-development-202/karazhan-chess-event-126093/
Look for the trigger folder "Player Specific", I think the trigger is called something like "Unit is selected".

However, can you elaborate on: "if the distance between the Unit (Selected Unit) and the Owner of the Unit who select are lower then xxx."
A distance between a player and the unit they picked? Well for me its going to be about two metres... ;)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Thats why I asked: Distance between SELECTED Unit and the OWNER of Unit - who select the Unit.

For example
  • (Integer((Distance between (Position of (SELECTED UNIT)) and (Position of (Unit controlled by Player - who do the Select))))) Less than or equal to 0
@ Dr Super Good: Dont understand :wscrolleyes:
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Ok hard missunderstandings here?^^ dont know but now:

I got 1 Unit - standing on the map, controlles by Neutral Passive. (Unit X)
I got 1 Unit - controlled by a Player and can move around. (Unit Y)

Unit X got a Quest. Now Unit Y (and the controlling Player) want take this Quest and the Player (with Unit Y) click unit X, to get this Quest. Requierment: Unit Y distance to Unit X is lower then 600.

If I want create a trigger: Unit X is called "Selected Unit". But how I call Unit Y?

I can create a variable for Unit Y and the Trigger would be: "Selected Unit" and "Varaible". But I got more then 15 Heros - and for each one a variable and trigger with all range check. And I got more Quests. So variable option not so good.
 
Level 9
Joined
May 27, 2006
Messages
498
Uhh, you need variables to do that, there is no other way.
Just make an initialization trigger where you store the players heroes to variables when they are choosen (or whatever).

Assuming players are choosing heroes from a tavern, the storage trigger should look like this;
  • heroes
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Set Hero[(Player number of (Owner of (Buying unit)))] = (Sold unit)
Then you simply get the distance between the selected unit and the hero in the variable and check if its less than 600.
  • select
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - ... and so on for other players
    • Conditions
    • Actions
      • Set TempPoint1 = (Position of (Hero[(Player number of (Triggering player))])
      • Set TempPoint2 = (Position of (Selected unit))
      • If (All Conditions are True) then do ...
        • If - Conditions
          • (Integer((Distance between TempPoint1 and TempPoint2))) Less than or equal to 600
        • Then - Actions
          • your actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint1)
      • Custom script: call RemoveLocation(udg_TempPoint2)
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Jeah this sounds cool but I got a Question:

The "Set Hero ....." Variable.

What type is it and what exactly is the effect of this?
- If 10 Players choose a hero, ALL the 10 Heros are "in this variable"?

But I want that the player enter a circle in front of the hero they want... what must I do?
 
Level 9
Joined
May 27, 2006
Messages
498
The Hero variable is an arrayed unit variable (array means that the box in the variable creation window is checked, it allows using one variable to store different things)

When player 1 chooses a hero, then his hero is stored in Hero[1]. When player 2 does so, his hero will be stored in Hero[2], and so on. This means you can use single variable for few things at once, without them interfering with each other.

And in case you're selecting heroes using power circles... I assume you're using regions to do that. And probably you have separate triggers for each hero.

Anyway;
  • hero 1
    • Events
      • Unit - A unit enter region1
    • Conditions
    • Actions
      • Set Hero[(Player number of (Owner of (Triggering unit)))] = hero 1
Just repeat it for every hero you have.
 
Status
Not open for further replies.
Top