"Hunt players" feature

Moderator: GZDoom Developers

Post Reply
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

"Hunt players" feature

Post by Blue Shadow »

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.
User avatar
Ethril
Posts: 2677
Joined: Sun Nov 16, 2008 2:59 am
Location: with you in the dark

Re: "Hunt players" feature

Post by Ethril »

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
User avatar
Fishytza
Posts: 794
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: They/Them
Contact:

Re: "Hunt players" feature

Post by Fishytza »

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
	}
}
User avatar
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

Post by NeuralStunner »

I'm pretty sure all those functions could be used from a CustomInventory, to keep the monster's states a little cleaner.
User avatar
Yholl
Posts: 1955
Joined: Mon Dec 17, 2012 11:08 am
Location: Here, stupid.

Re: "Hunt players" feature

Post by Yholl »

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
	}
}
Oooh, that's quite nice. Mind if I use it in DoomRL Monsterpack? Delicious credits to you, of course.
This'd fit well into my plans for making everyone sad.
User avatar
Ravick
Posts: 2053
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: "Hunt players" feature

Post by Ravick »

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

Post by Blue Shadow »

FishyClockwork wrote:Ugly hacks ahoy! *ahem* Might wanna give this a try?

*code*
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.
User avatar
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

Post by NeuralStunner »

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.
User avatar
edward850
Posts: 5906
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: "Hunt players" feature

Post by edward850 »

NeuralStunner wrote:I still think an engine-side solution would be more reasonable, especially if max player count increases in the future.
Mind you, the player pointer system needs better handling of that just the same.
User avatar
Fishytza
Posts: 794
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: They/Them
Contact:

Re: "Hunt players" feature

Post by Fishytza »

Yholl wrote:Mind if I use it in DoomRL Monsterpack?
Why would I mind if I bothered posting it in the first place? Be my guest. :)
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: "Hunt players" feature

Post by Blue Shadow »

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:

Code: Select all

A_TransferPointer(AAPTR_PLAYER1, AAPTR_DEFAULT, AAPTR_DEFAULT, AAPTR_TARGET)
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?
User avatar
Fishytza
Posts: 794
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: They/Them
Contact:

Re: "Hunt players" feature

Post by Fishytza »

Blue Shadow wrote:But what exactly it's transferring from player 1?
Player 1 him/herself, literally. At least I think that's how it works.

Basically, that bit of code could be translated to:

Code: Select all

A_TransferPointer(SOMETHING_FROM_PLAYER1, FOR_MYSELF, PLAYER1_THEMSELVES, AS_MY_TARGET)
that very same wiki page you linked wrote:AAPTR_DEFAULT: The calling actor itself
I think AAPTR_DEFAULT is only invalid if the actor was using itself as a source.
[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)
Just my 2 cents, though. I'm sure FDARI (if he's still around) could explain it better.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: "Hunt players" feature

Post by Blue Shadow »

Thanks! It's all clear now.
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: "Hunt players" feature

Post by Blue Shadow »

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.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”