ID:1501244
 
Code:
mob/Login()
src.icon='player.dmi'
src<<'Iced Earth.ogg'
src.addname("[src.key]")
src.icon_state="default"
src.loc=locate(7,9,1)
maxplayers += 1
if(maxplayers < 8)
spawn(5){usr<<("Welcome to The Floor Is Always Lava!");}

world <<"[usr] has joined the game!"
else
if(maxplayers >= 8)
src<<("This server is full. Go find another homie.")
del usr


Problem description: There's the login code, but I'm trying to figure out a way the host can choose a map before starting the actual game. Currently there's only two playable levels in the game at the moment.

When the host boots up the game I want him to choose the map, and then once chosen that's where the players will spawn, etc. However, at the end of every round the host can choose if he wants to change the level.

Here's the current host based code.

var/game_started=0
world/New()
{
..();
spawn()
{
do
{
sleep(10);
}
while(players<8&&!game_started);
}
if(game_started){return;}
world<<"Starting the game in 30 seconds!";
spawn(300) //number / 10 = seconds.
{
if(game_started){return;}
world<<"Beginning game!";
spawn(){generateLava(locate(8,8,1), 10);}
}
}

mob
{
host
{
verb
{
Start_Game()
{
if(game_started){return;}
game_started=1
world<<"Game starting in 5 seconds!";
spawn(50)
spawn(){generateLava(locate(8,8,1), 10);} //HERE IS WHERE YOU ALTER THE CODE!
}
}
}
}

client
{
New()
{
..();
if(address==world.address||!address)
{
src.mob.verbs+=new/mob/host/verb/Start_Game;
}
}
}


var/players
var/center
var/radius


I'd be eternally grateful if someone could help me out.

I'd recommend looking into the world.host variable to start.
Also, did you know you can add procs as verbs as well?

So instead of
mob
host
verb
Start_Game()

// you can get
mob
proc
Start_Game()

mob.verbs += /mob/proc/Start_Game // Not sure about syntax


As far as choosing a map goes, I'd use a global list of maps and pick from that. Allowing the host to change maps at the end of the round is pretty much the same deal. Maybe something like this.

var
map = ""
list
maps = list("map1","map2","map3")

proc
mapSetup(var/mapname)
// generate map

mob
proc
SelectMap()
var/map = input(src, "which map?") in maps
mapSetup(map)
What about the lava, and making it spawn on the selected map? As you can see, the code is like this right now in regards to the whole concept of the game: avoiding lava as it floods the map.

var/game_started=0
world/New()
{
..();
spawn()
{
do
{
sleep(10);
}
while(players<8&&!game_started);
}
if(game_started){return;}
world<<"Starting the game in 30 seconds!";
spawn(300) //number / 10 = seconds.
{
if(game_started){return;}
world<<"Beginning game!";
spawn(){generateLava(locate(8,8,1), 10);}
}
}

mob
{
host
{
verb
{
Start_Game()
{
if(game_started){return;}
game_started=1
world<<"Game starting in 5 seconds!";
spawn(50)
spawn(){generateLava(locate(8,8,1), 10);} //HERE IS WHERE YOU ALTER THE CODE!
}
}
}
}
I've never seen spawn abuse like this before. 0.o

However, think about your problem. You need to know what ever line of your code does, better than us on the forums, after all - it is your game.

How do you set the location that you're spawning lava from currently? How would you change that?
In response to Pirion
Pirion wrote:
I've never seen spawn abuse like this before. 0.o

However, think about your problem. You need to know what ever line of your code does, better than us on the forums, after all - it is your game.

How do you set the location that you're spawning lava from currently? How would you change that?

If I had to guess, he seems to be using either a global proc or a host proc generateLave(var/turf, var/radius) function.

If you want things to expand from a radius, you could use view().

// I don't know how you generate lava so I'm just gonna put this out.
generateLava(var/turf/start, var/radius)
var/reactRadius = radius + 3 // In case you want more things to spawn from the first
// I'm using whole numbers because I'm assuming that your
// game is tile-based
for(var/index = 1, index <= radius, index ++)
sleep(rand(12, 25)) // I made up some numbers
for(var/turf/T in (view(start, index) - view(start, index - 1))
// I want to make sure only the outer ring gets lava-fied
// in this example, but it can work just as well.
// view(ref, dist) returns a list, and I'm subtracting the inner
// list of turfs from the outer list of turfs.
T.icon_state = "lava"

// Now let's see if we spawned another lava pit
if(pick(0, 1))
var/turf/Newstart = pick(view(start, radius + reactRadius) - view(start, radius))
generateLava(NewStart, radius) // This may make some old lava lava again, you may or may not
// want to address that.
else return


He is already doing that, he is pretty much asking us how to change his locate() to point to a place on the map.
locate(rand(1, maxx), rand(1, maxy), map.z))

?

EDIT: Forgot we don't use 0 index lists here.
If he uses the same size map, and places them on different z levels, he really only needs to set the z level.

var/z_level = 1
proc/PlacePlayer(mob/m)
//loop to move, so they don't spawn on-top of each-other.
while(!m.Move(locate(rand(2,world.maxx-1),rand(2,world.maxy-1),z_level)) //+1/-1 if the world has walls.
sleep(1)


proc/SpawnLarva()
var/turf_to_replace = locate(rand(2,world.maxx-1),rand(2,world.maxy-1),z_level) //+1/-1 if the world has walls.

In response to Pirion
Yeah, maps will all be the same size.
I feel like you really ought to learn what you're doing instead of asking the forums for help every step of the way. If you don't take the time to understand what people have already helped you with, you'll never understand your final product.
I'm doing my best with fooling around with the map code, and just can't figure it out.

client
{
New()
{
..();
if(address==world.address||!address)
{
src.mob.verbs+=new/mob/host/verb/Start_Game;
src.mob.verbs+=new/mob/proc/SelectMap()


}
}
}


var/players
var/center
var/radius

var
map = ""
list
maps = list("map001","map003","map004")

proc
mapSetup(var/mapname)


mob
proc
SelectMap()
var/map = input(src, "which map?") in maps
mapSetup(map)


I don't know where I should put my maps, there's three of them. Map001, Map003, and Map004. Not to mention, how to make every player load on that map when the host picks it.
No no no. Not 3 maps. Just 1 map with different z levels. You check the map selected and move the player to the corresponding z level.