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

Discuss all aspects related to modding Zandronum here.
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

#21

Post by Ivan » Sat Aug 26, 2017 8:05 pm

Sigh....

You use the TID on the projectile to access it, obviously...
=== 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

#22

Post by FranckyFox2468 » Sat Aug 26, 2017 8:18 pm

Ivan wrote:Sigh....

You use the TID on the projectile to access it, obviously...
Okay, how do you do that? Cause you keep telling me to do stuff as if i knew it but never explain how.
Don't think i'd be asking in the first place if i did.
Konda wrote: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.
Thanks for that, ill try it out.

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

#23

Post by Empyre » Sat Aug 26, 2017 9:41 pm

@Ivan, you told him to set the projectile's TID in the projectile's spawn state, but you didn't tell him how to do that. I would tell him how, but I don't know, either. I searched the ZDoom wiki, and I can't find it. It tells how to give a thing a Spawn ID and a Conversation ID, but not how to give a thing a TID.

@FranckyFox, once you have given the projectile a TID (like 30000), using the method I hope Ivan will tell us, you then use ThingChangeTID (30000, 1000 + pnum); in your script.
"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

#24

Post by FranckyFox2468 » Sat Aug 26, 2017 10:29 pm

Okay so, with some assistance from Konda's advice and a friend i managed to make this work:

Code: Select all

script 700 (VOID) NET
{
    int ProjecID = UniqueTID();
    Thing_ChangeTID(0, ProjecID);
    SetActivator(0, AAPTR_TARGET);
    int pnum = PlayerNumber();
    SetActivator(ProjecID);
    Thing_ChangeTID(0, 1000 + pnum);
}

script 701 (VOID) NET

{
   Thing_Damage2((PlayerNumber() + 1000 ), 999,"detonator"); 
}

script 702 DEATH

{
   SetActorState ((PlayerNumber() + 1000 ), "Canceled", TRUE);
}
the problem now is... that it will only work for 1 sticky bomb at the time. If they are shot one by one its fine, but if for instance i free time or something, when i use the detonator only 1 will explode. I am not sure how to fix this.

EDIT: Fixed that withh ACS_Executealways. Anyway thanks a lot Kondu. I should be good to keep going with this technique! ...for now... I'll have to test monsters now...

EDIT2: Nope, i tried this with a monster and a master relation:

Code: Select all

script 702 DEATH

{
   SetActorState ((PlayerNumber() + 1000 ), "Canceled", TRUE);
   Thing_Destroy((PlayerNumber() + 2000 )); 
}

script 800 (VOID) NET
{
    int MonsterID = UniqueTID();
    Thing_ChangeTID(0, MonsterID);
    SetActivator(0, AAPTR_MASTER);
    int pnum = PlayerNumber();
    SetActivator(MonsterID);
    Thing_ChangeTID(0, 2000 + pnum);
}

Code: Select all

TNT1 A 0 A_SpawnItemEx ("NootTurret", 56, 0, 5, 0, 0, 0, 0, SXF_TRANSFERTRANSLATION|SXF_SETMASTER)
It works perfectly fine on GZdoom but won't work at all on zandro. Zandro seems to ignore any form of master relationships. Not sure if there is a workaround that.

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

#25

Post by Empyre » Sat Aug 26, 2017 11:14 pm

You could replace the last two lines of script 700 with this one line:
Thing_ChangeTID(ProjecID, 1000 + pnum);
And similar for script 800.
"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

#26

Post by FranckyFox2468 » Sat Aug 26, 2017 11:19 pm

Empyre wrote:You could replace the last two lines of script 700 with this one line:
Thing_ChangeTID(ProjecID, 1000 + pnum);
And similar for script 800.
No script 700 works like a charm. But 800 completely ignores the master relationship. So i went to try Ru5tK1ng's matter because if i understand, the TID section assigns a TID on top of the player number apparently:

Code: Select all

TNT1 A 0 A_SpawnItemEx ("NootTurret", 56, 0, 5, 0, 0, 0, 0, SXF_TRANSFERTRANSLATION|SXF_SETMASTER, 0, 2000)
Doesn't do shit. Turret remains regardless if player dies or not. And i can't use master relation since zandro seems to give no shit about it. Works perfectly on Gzdoom but i want my mod to be multiplayer compatible so i won't really go anyhwere with that. and SXF_SETTARGET crashes the game.

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

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

#27

Post by Konda » Sat Aug 26, 2017 11:34 pm

I think you can take advantage of the fact that any spawned actor's first target is the actor (or player) which spawned it, until it executes A_Look or gets hurt. So if the spawned actor executes a script as soon as it's spawned, you can use SetActivatorToTarget instead of this actor pointer stuff.

Edit: Also please remove that "NET" from script 800 as that allows the players to execute the script from the console with the "puke" command... with them being the initial activator...

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

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

#28

Post by FranckyFox2468 » Sat Aug 26, 2017 11:53 pm

Konda wrote:I think you can take advantage of the fact that any spawned actor's first target is the actor (or player) which spawned it, until it executes A_Look or gets hurt. So if the spawned actor executes a script as soon as it's spawned, you can use SetActivatorToTarget instead of this actor pointer stuff.
Using your technique it ignores player death in both zandronum and gzdoom. With SetActivator(0, AAPTR_MASTER); it works on gzdoom atleast.

Code: Select all

script 800 (VOID) NET
{
    int MonsterID = UniqueTID();
    Thing_ChangeTID(0, MonsterID);
    SetActivatorToTarget(0);
    int pnum = PlayerNumber();
    SetActivator(MonsterID);
    Thing_ChangeTID(0, 2000 + pnum);
}

Code: Select all

TNT1 A 0 A_SpawnItemEx ("NootTurret", 56, 0, 5, 0, 0, 0, 0, SXF_TRANSFERTRANSLATION|SXF_SETMASTER)
Starting to think i should just drop my prototype wad here at this point.
Konda wrote: Edit: Also please remove that "NET" from script 800 as that allows the players to execute the script from the console with the "puke" command... with them being the initial activator...
And done. My bad ^^'

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

#29

Post by Empyre » Sun Aug 27, 2017 6:52 am

FranckyFox2468 wrote:
Empyre wrote:You could replace the last two lines of script 700 with this one line:
Thing_ChangeTID(ProjecID, 1000 + pnum);
And similar for script 800.
No script 700 works like a charm. But 800 completely ignores the master relationship. So i went to try Ru5tK1ng's matter because if i understand, the TID section assigns a TID on top of the player number apparently:

Code: Select all

TNT1 A 0 A_SpawnItemEx ("NootTurret", 56, 0, 5, 0, 0, 0, 0, SXF_TRANSFERTRANSLATION|SXF_SETMASTER, 0, 2000)
Doesn't do shit. Turret remains regardless if player dies or not. And i can't use master relation since zandro seems to give no shit about it. Works perfectly on Gzdoom but i want my mod to be multiplayer compatible so i won't really go anyhwere with that. and SXF_SETTARGET crashes the game.
My suggestion wasn't a fix for something broken, but a way to do the same thing with one fewer lines of code.

If you want to kill everything made by the player, turrets and projectiles alike, maybe A_KillChildren or A_RemoveChildren is what you want.
"For the world is hollow, and I have touched the sky."

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

#30

Post by Ivan » Sun Aug 27, 2017 8:58 am

For multiple projectile support now you need to devise a careful formula to distribute to your projectiles.

One such as this, will work: (assuming a max of 5 can be out there at once and the detonation blows up ANY bomb placed by you)

Thing_ChangeTID(0, PlayerNumber() + 1000 + 64 + (5 - 1) * PlayerNumber() + CheckInventory("BombsOutThere"));

The key thing to know is the "BombsOutThere" item, which you give from the projectile to the player in its spawn state using A_GiveToTarget. This will help keep track of the count of active bombs of the player. So when you put another bomb you'll correctly assign the proper TID. Important thing to note here is that, you must check the inventory of the "target" aka the player, not the projectile! It won't work otherwise.

Rundown of the formula:

- Assume TID 1001 on player. (This is PlayerNumber() + 1000, so pnum is 1)
- Assume you're shooting projectiles.
- TID order: 1 + 1000 + 64 + 4 * 1 + 0 => 1069 (This makes sense, because player 0's bombs will start from 1064 and end at 1068, which is 5), then 1070 and so on, ending at 1073. (Because the "BombsOutThere" item will be incremented as you put out more)

I hope it's clear now.
Empyre wrote:@Ivan, you told him to set the projectile's TID in the projectile's spawn state, but you didn't tell him how to do that. I would tell him how, but I don't know, either. I searched the ZDoom wiki, and I can't find it. It tells how to give a thing a Spawn ID and a Conversation ID, but not how to give a thing a TID.
Like this:

Code: Select all

Spawn:
    TNT1 A 0 NoDelay Thing_ChangeTID(0, 3000)
    ...
Empyre wrote: If you want to kill everything made by the player, turrets and projectiles alike, maybe A_KillChildren or A_RemoveChildren is what you want.
If he knows the TID of things to kill (using a formula like above) he can just use Thing_Damage or Thing_Damage2.
=== 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

#31

Post by FranckyFox2468 » Sun Aug 27, 2017 3:12 pm

I'll check ivan's thing when i'm a little more woke up and in the mood for doom modding, but thanks in advance for the post.
EDIT: My problem is not projectiles anymore but monsters rn. They ignore completely target/master relationships for some reason.
Empyre wrote: If you want to kill everything made by the player, turrets and projectiles alike, maybe A_KillChildren or A_RemoveChildren is what you want.
I literally just said zandronum ignores completely any form of master/child relation ship between the player and a monster regardless of what i do no matter the version last night.
My code works but only on gzdoom. But a problem i run in is that it seems to ignore targetting as well. I use the latest build of zandro 3.0 on top of that so its really weird.

Ima put my wad for people to check directly but just a fair warning some coding is pretty messy and mostly contains leftovers of a scrapped mod i used for prototyping.
https://mega.nz/#!NBVFTbLb!PNHnMhtMyIp9 ... x119KyTD0U
Item in question is NootturretD, (Btw don't scream at the way i code please i won't really see that as constructive critisism). Upon using the item you spawn a turret. What it is supposed to do that any versions of zandro completely ignores is when the player dies, the turret dies as well, and if a turret is already deployed and you spawn another, the last turret dies. While you are at it you can witness the sticky bombs from its launcher (slot 5) works perfectly using the almost exact same code for some reason.

So yeah it works on GZDOOM but right now the issue is that i want it to work for zandro and since it refuses to work i'll need help finding a work-around :/
Last edited by FranckyFox2468 on Sun Aug 27, 2017 3:29 pm, edited 1 time in total.

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

#32

Post by Empyre » Sun Aug 27, 2017 3:28 pm

Ivan wrote:

Code: Select all

Spawn:
    TNT1 A 0 NoDelay Thing_ChangeTID(0, 3000)
    ...
I thought that you can only use the functions that start with A_ in DECORATE.
"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

#33

Post by FranckyFox2468 » Sun Aug 27, 2017 3:30 pm

Empyre wrote:
Ivan wrote:

Code: Select all

Spawn:
    TNT1 A 0 NoDelay Thing_ChangeTID(0, 3000)
    ...
I thought that you can only use the functions that start with A_ in DECORATE.
Nope, you can use all variants of ACS_Execute in decorate as well and many other things. Trust me i was surprised too when i found out.

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

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

#34

Post by FranckyFox2468 » Mon Aug 28, 2017 1:32 am

So a friend got me into a lead for a mod called Humans vs Ghouls: Nordic Saga that managed to do what i tried to do. I went to get it with doomseeker (cause all links on this forum were dead) and it partially works with some issues (such as if you die and respawn, you spawn dummy neutral sentries for some reason) but figured these could be issues that could be fixed.

But the real problem was, it was encrypted ACS stuff with no text file containing the stuff.

Guess i'll remain stuck in the mean time and if i don't find help or a workaround this issue i'll have to scrap this project .-.

Doesn't help that zandro puts master/child/target or whatever relationship between the summoner player and the monster has up its arse, cause most working solutions using player numbers i was offered involved that so...

edit: HAHA! i think i finally managed to understand what Ivan has been trying to tell me! Cause it works!

Code: Select all

TNT1 A 0 A_SpawnItemEx ("NootTurret", 56, 0, 5, 0, 0, 0, 0, SXF_TRANSFERTRANSLATION|SXF_SETMASTER, 0, tid)

Code: Select all

script 702 DEATH

{
   SetActorState ((PlayerNumber() + 1000 ), "Canceled", TRUE);
   Thing_Destroy((PlayerNumber() + 12000 )); 
}

script 800 (VOID)
{
    int TurrID = ActivatorTID();
    Thing_ChangeTID(0, 2000 + TurrID);
}
So i think i finally have this solved! Thanks for the help everyone!

Post Reply