Player spawn and 3D Floor trouble

Discuss all aspects related to modding Zandronum here.
User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Player spawn and 3D Floor trouble

#1

Post by Rheap » Wed May 04, 2016 5:31 pm

Hi all, i have a trouble with player spawn in GZDoom Builder. In my map i have create a 3D Floor, and i pose the player start thing over the 3D Floor, i run a test but i spawn in the floor no on the 3D Floor. So i try to use a little script with Teleport Destination that is:

Code: Select all

#include "zcommon.acs"

Script 1 Enter
{
Teleport(TID,0,1); 
} 
(i replace TID with the tag of player thing)
Another test works great, but when i try to create a server on Zandronum with this map after i click join the game, the first time i spawn on 3D Floor, but after death i don't respawn on 3D Floor.

What i do to fix this?

TheMisterCat
 
Posts: 79
Joined: Mon Jun 04, 2012 2:21 pm
Location: NZ

Re: Player spawn and 3D Floor trouble

#2

Post by TheMisterCat » Wed May 04, 2016 5:36 pm

Code: Select all

Script 2 RESPAWN
{
	ACS_Execute(1, 0);
}

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#3

Post by Rheap » Wed May 04, 2016 5:41 pm

TheMisterCat wrote:

Code: Select all

Script 2 RESPAWN
{
	ACS_Execute(1, 0);
}
Thanks works great, but the number one is the number of the tag of player start?

User avatar
Sean
IRC Operator
Posts: 982
Joined: Thu Jan 16, 2014 9:09 pm
Location: United Kingdom
Clan: Zandronum
Clan Tag: [Za]
Contact:

Re: Player spawn and 3D Floor trouble

#4

Post by Sean » Wed May 04, 2016 6:24 pm

No, it's script #1...
<capodecima> i dont say any more word without my loyer jenova

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#5

Post by Rheap » Wed May 04, 2016 6:25 pm

Ok, and if i want to insert more player spawn, i only need to duplicate the first script many times?

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: Player spawn and 3D Floor trouble

#6

Post by SwordGrunt » Wed May 04, 2016 7:16 pm

I'm not sure if this is from ZDoom 2.6+ (not supported by the current official Zandronum) but try it regardless. Set the Z height of your player spawns so that you spawn on the 3D floor, and use the MAPINFO property "UsePlayerStartZ" in your map definition.

If that doesn't work, just use this:

Code: Select all

#include "zcommon.acs"

#define	basetele	10

script 1 enter
{
	Teleport(PlayerNumber() + basetele, 0, 0);
}

script 2 respawn
{
	Teleport(PlayerNumber() + basetele, 0, 0);
}
Where your teleport destinations are numbered 10, 11, 12, etc. (counting up from the number defined as basetele)

User avatar
Sean
IRC Operator
Posts: 982
Joined: Thu Jan 16, 2014 9:09 pm
Location: United Kingdom
Clan: Zandronum
Clan Tag: [Za]
Contact:

Re: Player spawn and 3D Floor trouble

#7

Post by Sean » Wed May 04, 2016 8:37 pm

Rheap wrote:Ok, and if i want to insert more player spawn, i only need to duplicate the first script many times?
Only if you want useless redundant code that just runs the same thing multiple times.
<capodecima> i dont say any more word without my loyer jenova

Konda
Forum Regular
Posts: 487
Joined: Thu Jun 07, 2012 5:22 pm

Re: Player spawn and 3D Floor trouble

#8

Post by Konda » Wed May 04, 2016 9:00 pm

Rheap wrote:Ok, and if i want to insert more player spawn, i only need to duplicate the first script many times?
You don't need to duplicate the scripts. You actually have to duplicate the "Teleport destination" things and give each one of them a different TID. Then you need to figure out a way to teleport each player to a different teleport destination so players don't telefrag each other if they enter/respawn at the same time. SwordGrunt provided a way to do that in the script he posted. If you use his script, then you just have to give the teleport destination items the TIDs of 10, 11, 12, 13, ... (which he already mentioned in his own post... I'm blind)

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#9

Post by Rheap » Thu May 05, 2016 1:37 pm

Konda wrote:
Rheap wrote:Ok, and if i want to insert more player spawn, i only need to duplicate the first script many times?
You don't need to duplicate the scripts. You actually have to duplicate the "Teleport destination" things and give each one of them a different TID. Then you need to figure out a way to teleport each player to a different teleport destination so players don't telefrag each other if they enter/respawn at the same time. SwordGrunt provided a way to do that in the script he posted. If you use his script, then you just have to give the teleport destination items the TIDs of 10, 11, 12, 13, ... (which he already mentioned in his own post... I'm blind)
Ok good, but the TIDs i need to insert where is basetele? or where is 10 the first teleport destination, and other teleport destination i set tag to 11, 12, 13? sorry for the dummy question, but with coding i'm not so good.

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: Player spawn and 3D Floor trouble

#10

Post by SwordGrunt » Thu May 05, 2016 2:25 pm

As I posted: #define basetele 10

10 is the tag of the teleport destination for player 1, 11 for player 2, 12 for player 3 and so forth. Note that this requires a teleport destination for every player.

Konda
Forum Regular
Posts: 487
Joined: Thu Jun 07, 2012 5:22 pm

Re: Player spawn and 3D Floor trouble

#11

Post by Konda » Thu May 05, 2016 4:42 pm

SwordGrunt wrote:As I posted: #define basetele 10

10 is the tag of the teleport destination for player 1, 11 for player 2, 12 for player 3 and so forth. Note that this requires a teleport destination for every player.
Yes. If you have 8 player starts, add 8 teleport destination items and give them TIDs of 10, 11, 12, 13, 14, 15, 16, 17

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#12

Post by Rheap » Thu May 05, 2016 4:49 pm

Ok, and the TID i need for any of teleport destination to replace 10 of basetele, or it's automatic?

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

Re: Player spawn and 3D Floor trouble

#13

Post by Lollipop » Thu May 05, 2016 5:31 pm

The script looks into the playernumber of the player, so you could call it automatic. Each player has a unique ID, the first player having the ID 0, the second player ID 1 and so on. The ACS function PlayerNumber() retrieves this information for the purposes of the script.
This way the only thing you have to do is to make teleport destinations with the TIDs 10 to 73, as there are a maximum of 64 players on a server. If your map is supposed to support fewer players than that, then you will of course not need that many IDs reserved for this purpose.

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#14

Post by Rheap » Thu May 05, 2016 6:03 pm

Lollipop wrote:The script looks into the playernumber of the player, so you could call it automatic. Each player has a unique ID, the first player having the ID 0, the second player ID 1 and so on. The ACS function PlayerNumber() retrieves this information for the purposes of the script.
This way the only thing you have to do is to make teleport destinations with the TIDs 10 to 73, as there are a maximum of 64 players on a server. If your map is supposed to support fewer players than that, then you will of course not need that many IDs reserved for this purpose.
I understand. In my map i want only 10 player spawn-

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

Re: Player spawn and 3D Floor trouble

#15

Post by Lollipop » Thu May 05, 2016 7:20 pm

I see, but do you still want support for more players than 10? Then the script has to be reworked slightly:

Code: Select all

#include "zcommon.acs"

#define	basetele	10

script 1 enter
{
	Teleport((PlayerNumber()%10) + basetele, 0, 0);
}

script 2 respawn
{
	Teleport((PlayerNumber()%10) + basetele, 0, 0);
}
The % is the modulo operator, it gives the remainer of a division of whole numbers or something like that, I don't remember the exact definition. Just set it to the number after it to your desired number of spawns.
The reason it has to be reworked like this if you want 11+ player support for your map with ten spawns is because the 11th player would try to teleport to a teleport location that does not exist on the map.
I don't know if you will need this, but it's here in case you do. ;)

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#16

Post by Rheap » Thu May 05, 2016 7:26 pm

exist a method to test if every spawn work correctly?

Konda
Forum Regular
Posts: 487
Joined: Thu Jun 07, 2012 5:22 pm

Re: Player spawn and 3D Floor trouble

#17

Post by Konda » Fri May 06, 2016 1:51 pm

Rheap wrote:exist a method to test if every spawn work correctly?
When you run the game, open the console and spam this command: addbot

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#18

Post by Rheap » Sat May 07, 2016 11:44 am

Lollipop wrote:I see, but do you still want support for more players than 10? Then the script has to be reworked slightly:

Code: Select all

#include "zcommon.acs"

#define	basetele	10

script 1 enter
{
	Teleport((PlayerNumber()%10) + basetele, 0, 0);
}

script 2 respawn
{
	Teleport((PlayerNumber()%10) + basetele, 0, 0);
}
The % is the modulo operator, it gives the remainer of a division of whole numbers or something like that, I don't remember the exact definition. Just set it to the number after it to your desired number of spawns.
The reason it has to be reworked like this if you want 11+ player support for your map with ten spawns is because the 11th player would try to teleport to a teleport location that does not exist on the map.
I don't know if you will need this, but it's here in case you do. ;)
But why work only one spawn and the other no? on the first i insert TID 10, the other 11, 12, 13.... but don't work other and if i test with spawn a bot, the bot don't spawn on 3D Floor.

I can't understand where i do wrong. (but the modulo operator exactly what is?)

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: Player spawn and 3D Floor trouble

#19

Post by SwordGrunt » Sat May 07, 2016 1:42 pm

Modulating takes a number and essentially "limits" it to the passed divisor. It returns the remainder of the division, which will always be between 0 and 9 since you are dividing by 10. This means that players 0-9 will be teleported to destinations 10-19, and players 10-19 will also be teleported to destinations 10-19 in the same order, and so forth. This makes it so you only 10 teleport destinations for an unlimited amount of players - if you want to use less teleport destinations, such as four, change the %10 to %4 instead and you'd then only need spots with TIDs 10, 11, 12, 13.

I don't see anything wrong with that script. Did you set the Z height properly for all the teleport destinations?

User avatar
Rheap
 
Posts: 26
Joined: Tue Apr 05, 2016 3:39 pm

Re: Player spawn and 3D Floor trouble

#20

Post by Rheap » Sat May 07, 2016 3:31 pm

SwordGrunt wrote:Modulating takes a number and essentially "limits" it to the passed divisor. It returns the remainder of the division, which will always be between 0 and 9 since you are dividing by 10. This means that players 0-9 will be teleported to destinations 10-19, and players 10-19 will also be teleported to destinations 10-19 in the same order, and so forth. This makes it so you only 10 teleport destinations for an unlimited amount of players - if you want to use less teleport destinations, such as four, change the %10 to %4 instead and you'd then only need spots with TIDs 10, 11, 12, 13.

I don't see anything wrong with that script. Did you set the Z height properly for all the teleport destinations?
Now works, but there is a trouble: when i test it with max 3-4 bots no problem, when i spawn more than 3-4 bots some spawn on floor and not on 3D floor (the spawnpoint are like 20). How i can fix? or i send you the map, so you can control if some is incorrect?
Last edited by Rheap on Sat May 07, 2016 4:06 pm, edited 2 times in total.

Post Reply