"Hunt players" feature
Moderator: GZDoom Developers
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
"Hunt players" feature
Could there be a feature that allows a monster, a hostile one, to explicitly hunt players without the need to see or hear them first? Since what I want this for is not map-oriented, Thing_Hate won't do it, as it seems to involve messing about with tids, something that I'd like to avoid. What I'd like is a DECORATE solution, an actor flag or a flag for A_LookEx, maybe?
If the above is already possible, then I'd appreciate it if someone directs me to it.
If the above is already possible, then I'd appreciate it if someone directs me to it.
Re: "Hunt players" feature
I'm not sure (I'll check in a minute) but I think you can accomplish this just by having their Spawn state lead directly into their See state instead of looping.
edit: okay that didn't work
i swear i've done something like this that worked but i can't remember how
edit: okay that didn't work
i swear i've done something like this that worked but i can't remember how
Re: "Hunt players" feature
Ugly hacks ahoy! *ahem* Might wanna give this a try?
Code: Select all
Actor HostileOnSpawn : ZombieMan
{
States
{
Idle:
Goto Super::Spawn
Spawn:
TNT1 A 0 NoDelay A_TransferPointer(AAPTR_PLAYER1, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER2, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER3, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER4, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER5, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER6, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER7, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
TNT1 A 0 A_TransferPointer(AAPTR_PLAYER8, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET)
Goto Super::Spawn
FoundPlayer:
TNT1 A 0 A_PrintBold("found a player!") //Just a message to tell you it works
Goto See
}
}- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: "Hunt players" feature
I'm pretty sure all those functions could be used from a CustomInventory, to keep the monster's states a little cleaner.
Re: "Hunt players" feature
Oooh, that's quite nice. Mind if I use it in DoomRL Monsterpack? Delicious credits to you, of course.FishyClockwork wrote:Ugly hacks ahoy! *ahem* Might wanna give this a try?
Code: Select all
Actor HostileOnSpawn : ZombieMan { States { Idle: Goto Super::Spawn Spawn: TNT1 A 0 NoDelay A_TransferPointer(AAPTR_PLAYER1, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER2, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER3, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER4, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER5, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER6, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER7, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) TNT1 A 0 A_TransferPointer(AAPTR_PLAYER8, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET) TNT1 A 0 A_CheckFlag("SHOOTABLE", "FoundPlayer", AAPTR_TARGET) Goto Super::Spawn FoundPlayer: TNT1 A 0 A_PrintBold("found a player!") //Just a message to tell you it works Goto See } }
This'd fit well into my plans for making everyone sad.
Re: "Hunt players" feature
Couldn't it be done by just using "Thing_hate" in the monsters Spawn state? (Maybe with the need of player to have a TID, I guess.)
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "Hunt players" feature
Thanks for the code, but could you or somebody else explain how the transfer pointer part works? I've tried the code, and it seems to work, but I'd like to know how it's working, and that specific part is just confusing me a little.FishyClockwork wrote:Ugly hacks ahoy! *ahem* Might wanna give this a try?
*code*
- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: "Hunt players" feature
It's cycling through pointers to each player and determining whether they exist (by checking for a flag that a valid player actor would have set). It's manually assigned to Target each time so the monster can begin the chase immediately.
I still think an engine-side solution would be more reasonable, especially if max player count increases in the future.
I still think an engine-side solution would be more reasonable, especially if max player count increases in the future.
Re: "Hunt players" feature
Mind you, the player pointer system needs better handling of that just the same.NeuralStunner wrote:I still think an engine-side solution would be more reasonable, especially if max player count increases in the future.
Re: "Hunt players" feature
Why would I mind if I bothered posting it in the first place? Be my guest.Yholl wrote:Mind if I use it in DoomRL Monsterpack?
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "Hunt players" feature
Again, I get the general idea of what the code is trying to achieve, yet, again, the transfer pointer part that I'm not sure about. Lets take this, for example, from the above code:
It appears to be transferring something from player 1 to the calling actor. But what exactly it's transferring from player 1? What actor that's stored in the DEFAULT pointer of the player?
Oh, and for the sourcefield (and recipientfield), the [wiki=A_TransferPointer]wiki states[/wiki] that neither NULL nor DEFAULT are allowed. Is that true?
Code: Select all
A_TransferPointer(AAPTR_PLAYER1, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)Oh, and for the sourcefield (and recipientfield), the [wiki=A_TransferPointer]wiki states[/wiki] that neither NULL nor DEFAULT are allowed. Is that true?
Re: "Hunt players" feature
Player 1 him/herself, literally. At least I think that's how it works.Blue Shadow wrote:But what exactly it's transferring from player 1?
Basically, that bit of code could be translated to:
Code: Select all
A_TransferPointer(SOMETHING_FROM_PLAYER1, FOR_MYSELF, PLAYER1_THEMSELVES, AS_MY_TARGET)I think AAPTR_DEFAULT is only invalid if the actor was using itself as a source.that very same wiki page you linked wrote:AAPTR_DEFAULT: The calling actor itself
[EDIT]AAPTR_DEFAULT would be invalid if trying to assign yourself as your own target/master/tracer. And you can't use AAPTR_NULL as source or recipient.[/EDIT]
IE this would be invalid:
Code: Select all
A_TransferPointer(AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TRACER)
(from me, to me, myself, as my tracer)-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "Hunt players" feature
Thanks! It's all clear now.
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "Hunt players" feature
This can be closed now that we have scripting; I borrowed this code from the Icon of Sin. It doesn't exactly do what Fishy's code above does, but it's good enough for my use case.
