ID:165157
 
Basically I have never actually done this but I am working, or tryin to work on an infilitration type game, basically I dont fully understand how to implement a random spawn system using set locations... Might sound cofusing so i'l show you what I mean:

obj/Spawns
icon = 'player.dmi'
invisibility = 100
Infiltrator
icon_state = "inf"
Defender
icon_state = "def"


And a cropt pic of the map:
Free Image Hosting at www.ImageShack.us

Basically I want to place these spawns in different places and have it so that when people join in the game there is a chance that they are a defender or infiltrator and that they also get placed at one of these random spawns...

Theres probably a simple solution to this but you guys know best.
Hopefully you'll reply to this as well considering this has nothing to do with Naruto or "How do I learn how to code" type topics.

Thanks in advance.
mob
proc
Deathcheck(mob/M as mob)
if(M.hp<=0)
if(M.class == "Defender")
M.loc = locate(1,1,1)
else
M.loc = locate(1,2,3)


Im not sure if this is what you want.

- Miran94
In response to Miran94 (#1)
That's terriable Miran. You should always pass src as the person dieing. And that's not what he wanted anyway.
And you didn't setup the health check right.
(Please read the DM Guide!)

It's as easy as pick()-ing the object, and locating src to the object's location.
In response to Flame Sage (#2)
I didnt really understand I just made this in 5 seconds. as an example.
In response to Miran94 (#3)
Well, if you're going to make an example for someone, try to make it as efficient as possible, because.. they'll probably just copy and paste the code anyway. :)
In response to Flame Sage (#4)
Good point. Note to self make broken code for people so they stop asking for help and read the DM guide lol.
In response to Miran94 (#5)
Thanks Miran but thats not what I wanted, I knew how to do that anyway, so ehm... Flame how would I use pick() with this? Should I make a list containing the spawns and then get it to pick from that?

Something like:
var/Spawns = list()
for(var/obj/Spawns/Defender/D in world)
Spawns += D
pick(Spawns)
In response to Lyndonarmitage1 (#6)
There's a few things that go into this type of thing.

1) Do you want the teams to be even or completely random?
2) If you want them to spawn randomly on those spots, you'll need to add all those locations into a list and pick on from them (taking what team they're on into account)

Part 1 influences part 2 so I can't help you until you answer that question.
In response to Pyro_dragons (#7)
Teams are randomly generated on login and i have done the spawning using pick() now, if you like you can still help me out because I want this game to actualy be ranked XD