[ACS] (SOLVED)Question about Player TID and summons/projectiles

Discuss all aspects related to modding Zandronum here.
User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] (SOLVED)Question about Player TID and summons/projectiles

#1

Post by FranckyFox2468 » Thu Aug 24, 2017 1:51 pm

So by now i figured that assigning players TIDs is quite useful in doom. But there is one thing i wonder if its even possible to do in the first place.

So i'll start with my question, is it possible to assign a projectile or a player summon a TID with the player number so it can be used to destroy them for a DISCONNECT, RESPAWN or DEATH script?

Like i am really not sure how i would proceed in the first place because when i do so i usually use the default TARGET assignement from projectiles to verify stuff. But for instance, let's say the player shoots a sticky bomb from a gun (with a_firecustommissile or something). The sticky bomb is perhaps assigned a TID followed by a player number. Or perhaps summons a turret/monster. So if a monster/projectile with already said TID has been summoned by said player, the player dies or disconnects from the game, said monster/projectile is destroyed. (So it avoids a clusterfuck and spams if a player leaves or switch player class).

Now question is, is this possible in the first place? Cause i haven't managed to find a lead that could help me get a start at doing a such thing even by checking the wiki. It just says how to assign players TIDs but not if i can make use of them in such circumstances.

EDIT: In case its not clear enough ill give some context: I want to try doing a mod where player can deploy stuff either via a_spawnitemex or a_firecustommissile. Like sticky bombs, turrets, summons. All assign themselves a TID related to the summoner player number upon a script call in their spawning state. The problem with most mods with summons and such is that if a player dies or disconnects from a multiplayer game or changes class, the stuff is still here. I want to make a script that, similar to TF2 for exemple, if upon a RESPAWN or DISCONNECT, the player is not found anymore or changed class that does not used the currently deployed summons, a script call like thing_destroy or SetActorState triggers on the TID of the summons + the player number on the script. Problem is i am not sure to proceed and if i can even use TID+player number on a TID section of a script to begin with and when i am explained i am not provided much exemples. This is mostly for an experimental prototype i intend to do so check if a certain project will be possible in the first place so if you can help it would be appreciated.
Last edited by FranckyFox2468 on Mon Aug 28, 2017 2:30 pm, edited 3 times in total.

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

[ACS] Re: Question about Player TID and summons/projectiles

#2

Post by Ivan » Thu Aug 24, 2017 3:43 pm

Player TID: X
Turret TID: X + 64.

You can handle the rest I assume, just assign TID to spawned objects relative to the player TID.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#3

Post by FranckyFox2468 » Thu Aug 24, 2017 4:12 pm

Ivan wrote:Player TID: X
Turret TID: X + 64.

You can handle the rest I assume, just assign TID to spawned objects relative to the player TID.
That...... is....... awfully vague. I know you can assign TIDs but that does not answer my questions.
Like it doesn't answer how assignement work on the particular case i precised actually works or if this even works with thing such as a_firecustommissile or a_spawnitemex or whatever.

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

[ACS] Re: Question about Player TID and summons/projectiles

#4

Post by Ivan » Thu Aug 24, 2017 4:47 pm

Ok. I'll walk you through this.

Weapon shoots projectile. Player's TID is known. Projectile runs script on death.

You set activator to target. That's your player. Create new object using Spawn or whatever ACS function.

Spawn has a tid parameter. You know player's TID. Do what I said in my first post here and you'll have success.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#5

Post by FranckyFox2468 » Thu Aug 24, 2017 5:24 pm

Yeah but if i give the newly spawn thing a "setactivator" to the player to assign a new TID, won't that give the TID to the player instead of the newly summoned thing?
Cause what i want to be able to do is if specific TID+Playernumber is found or something, upon certain script it triggers them or destroys them.

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

[ACS] Re: Question about Player TID and summons/projectiles

#6

Post by Ivan » Thu Aug 24, 2017 5:34 pm

FranckyFox2468 wrote:Yeah but if i give the newly spawn thing a "setactivator" to the player to assign a new TID, won't that give the TID to the player instead of the newly summoned thing?
Cause what i want to be able to do is if specific TID+Playernumber is found or something, upon certain script it triggers them or destroys them.
Yeah just use Disconnect script and subtract a number from player's tid... It's very straightforward.

Also the activator is MEANT TO BE THE PLAYER so that you can SET THE TID RELATIVE to the player. That's kind of the point :)
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#7

Post by FranckyFox2468 » Thu Aug 24, 2017 5:40 pm

Okay but let's say i use a script like Thing_Destroy, how do i set a TID with a player number in the TID section of a script?

EDIT: Could you provide a script exemple or something? Like i appreciate your help but i have trouble understanding you ^^'

Catastrophe
Retired Staff / Community Team Member
Posts: 2558
Joined: Sat Jun 02, 2012 2:44 am

[ACS] Re: Question about Player TID and summons/projectiles

#8

Post by Catastrophe » Thu Aug 24, 2017 6:19 pm

FranckyFox2468 wrote:Okay but let's say i use a script like Thing_Destroy, how do i set a TID with a player number in the TID section of a script?

EDIT: Could you provide a script exemple or something? Like i appreciate your help but i have trouble understanding you ^^'
Look at this: https://zdoom.org/wiki/script_types#DISCONNECT

You see that when a player disconnects, the game lets you know what his playernumber was. Most people set player tid's to 1000 + playernumber, so to get the player tid based on that example, you'd do 1000 + gone (This is if you are assigning players a TID, if not then don't add 1000). Likewise, if you are following Ivan's example and need to know the tid of the projectile, then you'd do 1000 + gone + 64 (Again, don't add 1000 if you aren't giving the player a TID).

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#9

Post by FranckyFox2468 » Thu Aug 24, 2017 6:48 pm

Guess i'll try something perhaps this weekend and bring you guys some news to what will probably be a failure for now.

User avatar
Ru5tK1ng
Frequent Poster Miles card holder
Posts: 794
Joined: Fri Jun 01, 2012 9:04 pm

[ACS] Re: Question about Player TID and summons/projectiles

#10

Post by Ru5tK1ng » Thu Aug 24, 2017 8:16 pm

It's not that difficult. All you have to do is make an Enter script that fires every time a player enters the server for that specific player. Since he is the activator you can set something like this from the ZDoom wiki:

Code: Select all

script 1 ENTER
{
	Thing_ChangeTID(0, 1000+PlayerNumber());
}
Which means a player with the playernumber of 0 has a TID of 1000, playernumber 2 has a TID of 1002 etc. When you spawn stuff from an action like A_SpawnItemEx, you can pass a TID to the newly spawned projectile or actor. If I have a weapon that spawns some minions and give them a tid that adds something like 400 to the player TID. This makes the monsters TID (1400) tied to the player. When a player dies, leaves or spectates, all you have to do is call the appropriate script (Death, Disconnect) and run something ghetto like this:

Code: Select all

script 934 Disconnect
{
    Thing_Damage( (PlayerNumber() + 1000 ) + 400, 999, MOD_EXTREME);
}

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#11

Post by FranckyFox2468 » Thu Aug 24, 2017 8:26 pm

aaaaaaaaaaaaaah, this helps a lot. Regardless i'll still test everything and come back with results, if anything.

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#12

Post by FranckyFox2468 » Fri Aug 25, 2017 6:36 pm

Hey i have an extra question.
if, let's say, i make a projectile that assigns itself a player TID+a specific TID after a script call upon spawning right?
To do that i have to set the activator as the player if i understand Ivan correctly.
But if i do that, won't that set the TID to the player and no not the projectile/summon?

Code: Select all

script 700 ///assignement
{
    SetActivator(0, AAPTR_TARGET);
    Thing_ChangeTID(0, 1000+PlayerNumber());
}

script 701 ///detonator
{
    Thing_Damage( (PlayerNumber() + 1000 ), 999, MOD_EXTREME);
}
Like, won't that kill the player instead?

EDIT: Starting to think assigning a player number to a variable would work better but im not sure if that would do anything.

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#13

Post by FranckyFox2468 » Fri Aug 25, 2017 8:09 pm

So i tried a script and i am kind of stuck here right now. So if anyone can help:

Code: Select all

script 700 ///assignement
{
    SetActivator(0, AAPTR_TARGET);
    ///Set some array like "n" equal to player number somehow i dunno how to do that
    SetActivator(0, AAPTR_DEFAULT); //supposed to return to the origin, thus the projectile? So it doesn't assign the TID to the player and create a suicide button
    Thing_ChangeTID(0, 1000+n);
    
}

script 701 (int PlayerNumber) DISCONNECT

{
    Thing_Damage( PlayerNumber + 1000 ), 999, MOD_EXTREME);
    
}

script 702 RESPAWN
{
    		if (Checkinventory("EngineerKit") >= 1) 
		{
                terminate;
		}
		else
			{
			Thing_Damage( (PlayerNumber() + 1000 ), 999, MOD_EXTREME);
			}

script 703 ///manual detonation

{
   Thing_Damage( (PlayerNumber() + 1000 ), 999, MOD_EXTREME);
    
}
EDIT:
Unless i misunderstood him i tried ivan's way

Code: Select all

script 700 (VOID) NET
{
    SetActivator(0, AAPTR_TARGET);
    Thing_ChangeTID(0, 1000+PlayerNumber());
}

script 701 (VOID) NET
{
    Thing_Damage( (PlayerNumber() + 1000 ), 999);
}
It pretty much creates a suicide button if i put that on a weapon.

User avatar
Empyre
Zandrone
Posts: 1316
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

[ACS] Re: Question about Player TID and summons/projectiles

#14

Post by Empyre » Fri Aug 25, 2017 8:51 pm

The idea is to assign to the player the TID 1000 + PlayerNumber(). The projectile's TID would be the player's TID + 64, or 1064 + PlayerNumber(). The number 64 is because there can be up to 64 players. This whole thing does assume that each player will have no more than one projectile, or that all projectiles belonging to a player would have the same TID.

The example script at the top of this page gives the player a TID of 300 + PlayerNumber(), and very wisely uses a constant for the starting number, so you could easily change your mind and make it 1000 instead of 300, by only changing that one line, rather than having to change it every line in the code that uses it, risking missing some of them.
"For the world is hollow, and I have touched the sky."

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#15

Post by FranckyFox2468 » Fri Aug 25, 2017 8:55 pm

Okay but that doesn't solve the problem of assigning the projectile a TID if its fired upon using a_firecustom missile. Unless the TID is assigned automatically upon firing?
Cause ivan talked about assigning a TID on the projectile upon it spawning and the connecting it to the player TID and... Man this whole thing is getting confusing <_>

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

[ACS] Re: Question about Player TID and summons/projectiles

#16

Post by Ivan » Fri Aug 25, 2017 9:11 pm

No you have to run a script and get the activator of that script, then assign a TID to the projectile.

To do this, assign the projectile an arbitrary TID like 30000 in it's spawn state, then change the thing with TID 30000 to PlayerNumber() + 1000 + 64 or whatever you want.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#17

Post by FranckyFox2468 » Fri Aug 25, 2017 9:15 pm

Ivan wrote:No you have to run a script and get the activator of that script, then assign a TID to the projectile.

To do this, assign the projectile an arbitrary TID like 30000 in it's spawn state, then change the thing with TID 30000 to PlayerNumber() + 1000 + 64 or whatever you want.
Okay but how do i get the player number cause the moment i change activator to the player once it won't change back to the projectile. I tried this and it won't do shit:

Code: Select all

script 700 (VOID) NET
{
    SetActivator(0, AAPTR_TARGET);
    int pnum = PlayerNumber();
    SetActivator(0, AAPTR_DEFAULT); //supposed to return to the origin, thus the projectile?
    Thing_ChangeTID(0, 1000 + pnum);
}

script 701 (VOID) NET

{
   SetActorState (PlayerNumber() + 1000 , "Boom", TRUE);

}

User avatar
Ivan
Addicted to Zandronum
Posts: 2219
Joined: Mon Jun 04, 2012 5:38 pm
Location: Omnipresent

[ACS] Re: Question about Player TID and summons/projectiles

#18

Post by Ivan » Sat Aug 26, 2017 10:10 am

FranckyFox2468 wrote:
Ivan wrote:No you have to run a script and get the activator of that script, then assign a TID to the projectile.

To do this, assign the projectile an arbitrary TID like 30000 in it's spawn state, then change the thing with TID 30000 to PlayerNumber() + 1000 + 64 or whatever you want.
Okay but how do i get the player number cause the moment i change activator to the player once it won't change back to the projectile. I tried this and it won't do shit:

Code: Select all

script 700 (VOID) NET
{
    SetActivator(0, AAPTR_TARGET);
    int pnum = PlayerNumber();
    SetActivator(0, AAPTR_DEFAULT); //supposed to return to the origin, thus the projectile?
    Thing_ChangeTID(0, 1000 + pnum);
}

script 701 (VOID) NET

{
   SetActorState (PlayerNumber() + 1000 , "Boom", TRUE);

}
Steps:

1. Set TID of projectile fired, in THE PROJECTILE'S SPAWN STATE, to an arbitrary number.
2. Have that projectile run the TID changing script.
3. Change the TID of the projectile using THAT ARBITRARY NUMBER you gave in its spawn state.

I think this should be clear now...
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Question about Player TID and summons/projectiles

#19

Post by FranckyFox2468 » Sat Aug 26, 2017 7:15 pm

Ivan wrote: Steps:

1. Set TID of projectile fired, in THE PROJECTILE'S SPAWN STATE, to an arbitrary number.
I did so

Code: Select all

Spawn:
    GL21 A 0 nodelay ACS_Execute (700)
	goto spawn2
So i have to do a script that changes its TID to a number like 100 right?

But that still doesn't resolve on getting the player number and giving it back to the projectile because once SetActivator has been used even once it won't go back to the projectile if used again.

Code: Select all

    SetActivator(0, AAPTR_TARGET);
    int pnum = PlayerNumber();
    SetActivator(0, AAPTR_DEFAULT); //supposed to return to the origin, thus the projectile?
    Thing_ChangeTID(0, 1000 + pnum);
I think you might as well put a code exemple at this way cause it feels like you've been explaining 5 different things now :neutral:

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

[ACS] Re: Question about Player TID and summons/projectiles

#20

Post by Konda » Sat Aug 26, 2017 7:57 pm

I'm not sure but I think the first state after the Spawn label shouldn't have any action function at all, and even if you put an action function in the first state the engine is just gonna ignore it.

Anyway, if you wanna return control of the script to the projectile, you first need to assign a unique tid to the projectile (you can use UniqueTID(1)) before setting the activator to the player, so later you can use the unique tid in SetActivator to set the projectile as the activator of the script again. Idk about this actor pointer stuff but this is how it's been done for a while now.

Post Reply