HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

change ownership of unit based on start location

01-10-2003, 03:11 PM#1
Guest
For the past few days I've been working on a 3-way capture the flag variant, where if you destroy a player's "flag" (an obelisk), that player is defeated.

The thing is, for obvious reasons I want the obelisk nearest the player start location to belong to that player. So now my map has obelisks that have their ownership set under unit properties. Also, I have fixed start locations.

I would like to have the start locations randomized, but the obelisks have to change ownership to be owned by the nearest player. Obviousle this needs to be done at startup... but how do I set the ownership to the *nearest* player start location (if at all posible)?


Graci,
RobC
01-10-2003, 03:26 PM#2
Guest
You could make it rescuable, or you could make them neutral and give them to the player that has a unit in region x (which would be over your town hall).

sorry I can't give you exact triggers, but Im at work. hope this helps.

Break.
01-10-2003, 03:56 PM#3
Aiursrage2k
I was going to try and explain my method, but right now I do not WE with me so, I will tell this. There are two ways of doing this, the first to set the player forces not to being 'fixed'. I belive this should randomize the start locations. Next, if you could extract blizzard.j, in it there is a function that finds the where the start location is, use this to spawn your obelisk.

If for some reason the method of randomization does not work, prehaps you only want some of the players to be randomized, for example special computer players. I can post a second method to do randomize this, later today.
01-10-2003, 05:43 PM#4
Guest
Not setting fixed start positions certainly does allow random start locations. I can't (don't know how to) get the .j files, and I don't know how to incorporate JASS in triggers anyway... so I'm still a bit confused. :(


Much thanks,
RobC
01-10-2003, 06:33 PM#5
BoddoZerg
Bah, why go to all the trouble of extracting JASS scripts for such an easy thing:

On Map Initialization:
Pick all players in group ( Players matching (Matching player is playing the game) ) and do:
Pick all units in Unit-Group (Units of type-Obelisk within range 1024 of (Picked Player Start Location)) and do:
Set Unit Owner to (Picked Player), changing color
01-10-2003, 09:46 PM#6
Guest
That looks cool. Much thanks!
Just to be sure, I have (a trigger with a very simple event/condition and an enormous action):

TRIGGER: Set Obelisks
EVENTS: Map initialization
CONDITIONS: -none-
ACTIONS: Pick every player in (All players matching(((Picked Player) is in (All Players)) Equal to True)) and do
(Unit Group - Pick every unit in (Units within 1024.00 of ((Picked player) start location) matching
(((Matching Unit) is in (Units of type Enchanted Gemstone Obelisk)) Equal to True)) and do
(Unit - Change ownership of (Picked unit) to (Picked Player) and Change color))

Come to think of it, shouldn't I just use "Pick every player in (All players) and do ..."?

How can I judge what the distance (1024) should be? My furtherest points are (-5122.6,4104.4,0)(-7303,628.1,256). Two-dimensionally they are about 4103 away from eachother... I guess I'll use 4500, since that is a safe distance still between each start location.
01-10-2003, 10:12 PM#7
MrDoomMaster
The easiest way of doing this is creating regions, one expanding over each start location... (or, over the spot where each player's units will be when you start the map). For the obelisks corresponding to each starting point, you would create a trigger of this form (keep in mind i didn't have world editor open for this, so some functions may not be exact... this is simply just so you may grasp an idea):

Events:
Map Initialization

Conditions:
Null

Actions:
if random unit in Region 1 owned by player X equal to true, then do: change obelisk 0001 ownership to player X

(repeat this function for every player in your map)

I based this funtion on picking one unit out of the region your units start off in, considering that i don't think any enemy units will be spawning with your group of units, so all units in that region should be owned by the same player. I hope i've helped. The whole distance thing seems to be a working method, but doesn't seem as flawless as my method.
01-10-2003, 10:53 PM#8
Guest
I have BoddoZerg's method working, with acceptable distance.

Thanks for the help... (regions idea looked cool too, and I wouldn't have had to calculate the distance :) )
01-11-2003, 05:00 AM#9
Aiursrage2k
I was creating a map something similar to bunker wars, using a randomization of the bunker spawn, and some other neat things. The actual gameplay of my map is not good, but the basic ideas are there.

Note: its not finished, but some of the triggers might be useful...