Team-based projectile help

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Team-based projectile help

Post by Ghastly »

For QNA, I'm trying to have team-based projectiles (Blue team fires blue blaster bolts, blue-flared rockets, blue lightning, blue railgun shots, etc.), and I already have an idea as to how to do it. I'll try a LoadACS script to check the player's team in Enter and Respawn scripts and give a cooresponding inventory item, which the weapon checks for.

How exactly would I use GetPlayerProperty to check a player's team, and would it mess up in single player? I'll double-check on the Skulltag forums to see if the ZDoom method would work properly in Skulltag, but I don't see too many reasons it wouldn't.

Edit: Ack, I should've checked the wiki more thoroughly first. I meant GetPlayerInfo, and PlayerInfo_Team was the first on the list XD. Thanks anyway!

Edit2: Yeah... Can someone give me an example of a script that checks the activating player's team?
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

Couldn't be more simple :P

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
	if(GetPlayerInfo(0, PLAYERINFO_TEAM) != 0) //if the player's team is not the default 0 (blue) they are killed
	{
		Thing_Damage(0, 100, 0);
	}
	else
	{
		//nothing
	}
}

script 2 (void)
{
	if(GetPlayerInfo(0, PLAYERINFO_TEAM) != 1) //if the player's team is not the default 1 (red) they are killed
	{
		Thing_Damage(0, 100, 0);
	}
	else
	{
		//nothing
	}
}
this is stuck to a linedef at the respective team's spawns, so any non blue/red people trying to enter the opposite team's spawn area are killed

EDIT: i made this to show my example at work:
example_team.wad
(2.72 KiB) Downloaded 22 times
try switching around teams and see what happens :lol:
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

Thanks, but does 0 really check for the activator, with GetPlayerInfo?
The wiki wrote:To get information for the player who activated the script, use the PlayerNumber function.
If this is right, how could I use it to get the activator's information, without assigning a PlayerNumber-based TID to everything?

Edit: Hm... It's not working in Skulltag. I started up CTF on that map (after adding team starts), and both teams trigger the killing line. Is there any alternative to GetPlayerInfo I can use to check a player's team?
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

perhaps you could stick a script to a linedef to find out the team number for blue/red/whatever other teams

Code: Select all

script 1 (void)
{
        SetFont("BIGFONT"); //so you can read it
        print(d:GetPlayerInfo(0, PLAYERINFO_TEAM)); //printing the team number of activator
}
this would be MUCH easier if the skulltag wiki actually had info about the team numbers :?

EDIT:
Ghastly_dragon wrote:Thanks, but does 0 really check for the activator, with GetPlayerInfo?
interesting... i guess not, and the script is only checking the first player that entered the game (who is 0) :oops:

you may not have a choice but to assign individual TIDs to each player
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

I just reported the Skulltag problem in Skulltag's internal testing IRC channel, and it was just fixed and will hopefully be in the next version. I just need some way to test in ZDoom, so I know if I'm successful or not.

I'd, also, like to clear up that whole GetPlayerInfo activator thing before I get started on the script itself. Can it check the activator, in spite of that one thing it says on the wiki?
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

No, i don't think it can, the only way to test it would to do a 2p game and test the scripts then, but i still believe that you may have to assign each player a unique TID
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

Okay, I just rigged this thing up:

Code: Select all

#Include "ZCommon.acs"

Script 1 Enter
{
Thing_ChangeTID(0, 1000 + PlayerNumber());
}

Script 2 Enter
{
If(GetPlayerInfo(1000 + PlayerNumber(), PlayerInfo_Team) == 0)
	{
	GiveActorInventory(0, "BlueTeamChecker", 1);
	}
Else
	{
	If(GetPlayerInfo(1000 + PlayerNumber(), PlayerInfo_Team) == 1)
		{
		GiveActorInventory(0, "RedTeamChecker", 1);
		}
	}
}

Script 3 Respawn
{
If(GetPlayerInfo(1000 + PlayerNumber(), PlayerInfo_Team) == 0)
	{
	GiveActorInventory(0, "BlueTeamChecker", 1);
	}
Else
	{
	If(GetPlayerInfo(1000 + PlayerNumber(), PlayerInfo_Team) == 1)
		{
		GiveActorInventory(0, "RedTeamChecker", 1);
		}
	}
}
Would Script 1 fire before Script 2? I'm concerned it won't, because my experience with Starcraft triggers is that the effects from one don't take effect before the next can use them.

I already wrote the decorate-side of this (which works perfectly, even, surprisingly, with the hold state weapons), so I just need some way to test it in ZDoom. Is there any mod I can run with this in ZDoom that uses teams?
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

Script 1 is basically changing EVERYthing that has no TID (0) to the TID of a non existant player (who activated it? not a player)
Script 2 is giving actors with TID 0 the blue team checker and getting the player info of a non existant player (see above
Script 3 is also like this.

You may need a TID reliant, but more modifiable system. if you want, i could try to write a system and PM it's source to you

EDIT: well, this reads rather embarrasingly
Last edited by NewTiberian on Tue Jul 22, 2008 3:21 am, edited 1 time in total.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

http://zdoom.org/wiki/Thing_ChangeTID "If oldtid is zero, then whatever activated the script will have its TID changed to newtid."

An Enter script is executed when a player enters the game, so any player that enters the game will get a TID unique to his player number.
User avatar
Macil
Posts: 2529
Joined: Mon Mar 22, 2004 7:00 pm
Preferred Pronouns: He/Him
Location: California, USA. Previously known as "Agent ME".
Contact:

Re: Team-based projectile help

Post by Macil »

Just combine scripts 1 and 2 into one script, there's no reason to have them separate.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

Er, how would I put an If in the middle of an execution like that? (I'm not all that great with ACS.)

Nevermind, I got it :lol:.
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

Ghastly_dragon wrote: An Enter script is executed when a player enters the game, so any player that enters the game will get a TID unique to his player number.
bah, you're right, i forgot the difference between Enter and Open scripts :oops:
in that case, it should work fine, but now i'm wondering if there is a way to grab a player's team info using a TID.
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

There is. GetPlayerInfo(TID, InfoType).
User avatar
Ghastly
... in rememberance ...
Posts: 6109
Joined: Fri Jul 06, 2007 2:34 pm

Re: Team-based projectile help

Post by Ghastly »

Okay, I'm still having a massive problem with this:

Code: Select all

#Include "ZCommon.acs"

Script 622 Enter
{
Thing_ChangeTID(0, 1000 + PlayerNumber());
If(GetPlayerInfo(1000 + PlayerNumber(), PLAYERINFO_TEAM) == 0)
	{
	GiveActorInventory(0, "BlueTeamChecker", 1);
	}
Else
	{
	If(GetPlayerInfo(1000 + PlayerNumber(), PLAYERINFO_TEAM) == 1)
		{
		GiveActorInventory(0, "RedTeamChecker", 1);
		}
	}
}

Script 623 Respawn
{
Thing_ChangeTID(0, 1000 + PlayerNumber());
If(GetPlayerInfo(1000 + PlayerNumber(), PLAYERINFO_TEAM) == 0)
	{
	GiveActorInventory(0, "BlueTeamChecker", 1);
	}
Else
	{
	If(GetPlayerInfo(0, PLAYERINFO_TEAM) == 1)
		{
		GiveActorInventory(0, "RedTeamChecker", 1);
		}
	}
}
When it uses ==, it doesn't work at all, but when using != (which I'm guessing means everything except the specified number), it does do something, but gives both teams the one item.

Edit: Okay, odd development: I think the problem lies with Thing_ChangeTID. After a few tests, I discovered that GetPlayerInfo is returning -1 ("If you ask for information about a player who is not in the game, it will return -1.").

I've tried Thing_ChangeTID in a seperate Enter script (lower script number, so it activates first, and even activating the GetPlayerInfo script to make sure of it), but it has the same effect. Any ideas?
User avatar
NewTiberian
Posts: 65
Joined: Fri Apr 04, 2008 5:18 pm
Location: Australia

Re: Team-based projectile help

Post by NewTiberian »

I presume the cause of most of the problem is that GetPlayerInfo wants a PlayerNumber, and not a TID.
a simple enter script like so should work:

Code: Select all

script 1 enter
{
	if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 0)
	{
      //commands here (such as giving the player Blue/RedTeamChecker)
	}
	else if(GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) == 1)
	{
		//commands here
	}
}
you could also replace the condition statements with Case statements, in case multiple teams are involved (more than 2)
(and by work, i mean full stop, it shouldn't need any more tinkering :lol: )
Locked

Return to “Editing (Archive)”