Lookers [Update 12/14/21]

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Lookers [Update 12/14/21]

Post by Hey Doomer »

While sprites are flat, they do show movement. Perhaps, a variety of movement gives an illusion of depth and life. Does changing a sprite angle add anything extra? This is the concept behind Lookers. Basically when a monster is spawned instead of dancing in place like it has a full bladder it also turns this way and that as though looking for something.

ZScript:

Code: Select all

class lookers_EventHandler : EventHandler
{
	PlayerInfo player;
	Array<Actor> monsters;
	ThinkerIterator MonsterFinder;
	int tCount;
	int spDir;

	void findMonsters(float distance)
	{
		monsters.Clear();
		Actor mo;
		MonsterFinder.Reinit();
		spDir = spDir == 15 ? -15 : 15;
		while (mo = Actor(MonsterFinder.Next()))
		{
			// note that Spawn is not detected by InStateSequence
			if (mo.bIsMonster && !mo.InStateSequence(mo.CurState, mo.ResolveState("Missile")))
			{
				float d = player.mo.Distance3D(mo);
				if (d < distance)
				{
					mo.A_SetAngle(mo.angle + spDir, SPF_INTERPOLATE);
					monsters.Push(mo);
				}
			}
		}
		// console.printf("Monsters found: %d, direction: %d", monsters.Size(), spDir);
	}
	override void WorldTick()
	{
		if (tCount < 70) // speed of change
		{
			tCount++;
		}
		else
		{
			findMonsters(1024);
			tCount = 0;
		}
	}
	override void PlayerSpawned(PlayerEvent e)
	{
		tCount = 0;
		spDir = 15;
		MonsterFinder = ThinkerIterator.Create("Actor");
		player = players[e.PlayerNumber];
	}
}
How this works is simple. Every 70 ticks a ThinkerIterator finds all monsters within 1024 distance. So long as the state isn't Missile, the monster angle is changed +/- 15 degrees. So when just spawned and A_Look is called, for example, a monster actually looks from side to side. Likewise when chasing it appears to look around.

This is rough and may have problems, although so far I like how it looks. The angle is changed within a perimeter, and I've no idea if it resets to a standard sprite angle once the player moves away (my guess is yes). Since I'm not tracking individual angles (for now pointers are added to an array until I decide) directions toggle back and forth, which can create a weird choreography. InStateSequence seems buggy (it doesn't detect Spawn, for one); for the present it seems OK to exclude Missile, since it makes sense in those cases that a monster face the player.

Still pondering...

Update 12/7/21
Spoiler:
Update 12/10/21
Spoiler:
Update 12/14/21
Spoiler:
Last edited by Hey Doomer on Tue Dec 14, 2021 7:45 am, edited 3 times in total.
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Bug report:- Seems to crash with VM aborted on console when dying on Map04 of Doom2...
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Lookers [Update 12/7/21]

Post by Hey Doomer »

thugsta wrote:Bug report:- Seems to crash with VM aborted on console when dying on Map04 of Doom2...
Thanks. Can you turn on devmode and let me know what the error is?
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Where is devmode to turn it on?

But here is what the console say properly
bug.jpg
You do not have the required permissions to view the files attached to this post.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Lookers [Update 12/7/21]

Post by Hey Doomer »

thugsta wrote:Where is devmode to turn it on?

But here is what the console say properly
bug.jpg
If you search in options for "dev" you'll see Developer message mode. Turn that on and you'll get the messages. Errors is probably sufficient.
User avatar
Enjay
 
 
Posts: 26574
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Lookers [Update 12/7/21]

Post by Enjay »

Or type "developer 2" at the console. That will put set developer mode to "warnings" level and that will probably do you too.

I usually keep developer mode at 2 because I spend as much time working on mods as I do playing them and I also like to see if any mods I play are flagging up important or interesting warnings.
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Weird, i do some mod work too but never knew of this command. Thanks.
bug2.jpg
Is this right now?
You do not have the required permissions to view the files attached to this post.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Lookers [Update 12/7/21]

Post by Hey Doomer »

thugsta wrote:Weird, i do some mod work too but never knew of this command. Thanks.
bug2.jpg
Is this right now?
Interesting. I don't see a crash playing "The Focus." There's nothing specific in this error, but the previous seems to refer to another script. Is it a different mod, I wonder? It still could be mine, just wondering.
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Not sure if it matters but, die near the beginning where those shutters are opening/closing.

I am mainly only playing with a bunch of your tweaks and and when i disable this one, the crashing stops.

Using:- Lookers, Clouds, Darker, Impact, Windows, Real elevators, Billboarder and Drag-Things

EDIT- Just tried it now with Lookers only and yes still the same error.
User avatar
Sarah
Posts: 551
Joined: Wed Sep 06, 2006 12:36 pm
Preferred Pronouns: She/Her
Operating System Version (Optional): Debian 11 (bullseye), Windows 10
Location: Middle of Nowheresville Il.

Re: Lookers [Update 12/7/21]

Post by Sarah »

@thugsta - if you mean this Real Elevators, then you can eliminate it from your load order. Real Elevators is a modder's resource and does nothing on its own; I will update my thread to make that clear, sorry for any confusion :D
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Nero wrote:@thugsta - if you mean this Real Elevators, then you can eliminate it from your load order. Real Elevators is a modder's resource and does nothing on its own; I will update my thread to make that clear, sorry for any confusion :D
Dang it, I was hoping it was usable as is from the usage description. Some acceleration would of been good on some of these big elevators in these custom maps with long rides, reminds me of Mass Effect all over again lol.

Thanks for the heads up.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Lookers [Update 12/7/21]

Post by Hey Doomer »

I've played this a few times using Lookers on MAP04, died, no errors.

No problems with all other mods loaded. I did get a similar error once that I couldn't reproduce. My guess is this is some conflict in using a null pointer. My code, for example, refreshes the looker but doesn't check after to see if the pointers aren't null.

Code: Select all

		Actor mo;
		MonsterFinder.Reinit();
		while (mo = Actor(MonsterFinder.Next()))
		{
			// note that Spawn is not detected by InStateSequence
			if (mo.bIsMonster && !mo.InStateSequence(mo.CurState, mo.ResolveState("Missile")))
			{
Not sure if this should be mo && mo.bIsMonster && etc. although I haven't seen a need so far for this. I suppose it's possible in addressing these during a firefight that one could be wiped out. I'm capturing everything not "Missile." Hmm... Probably should also exclude the Death states. The reason I've excluded Missile is because InStateSequence doesn't seem to work with Spawn.
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Hey Doomer wrote:I've played this a few times using Lookers on MAP04, died, no errors.

No problems with all other mods loaded. I did get a similar error once that I couldn't reproduce. My guess is this is some conflict in using a null pointer. My code, for example, refreshes the looker but doesn't check after to see if the pointers aren't null.

Code: Select all

		Actor mo;
		MonsterFinder.Reinit();
		while (mo = Actor(MonsterFinder.Next()))
		{
			// note that Spawn is not detected by InStateSequence
			if (mo.bIsMonster && !mo.InStateSequence(mo.CurState, mo.ResolveState("Missile")))
			{
Not sure if this should be mo && mo.bIsMonster && etc. although I haven't seen a need so far for this. I suppose it's possible in addressing these during a firefight that one could be wiped out. I'm capturing everything not "Missile." Hmm... Probably should also exclude the Death states. The reason I've excluded Missile is because InStateSequence doesn't seem to work with Spawn.
Weird :?: :shock: I literally had nothing else loaded other then your tweak (hell even disabled reshade to test just in case). Sure the first screenshot is on me forgetting to isolate the problem with the new addon if there was a conflict but the second screenshot when loaded with this single tweak i could reproduce it over and over again. I hammer enter to start a new game asap, bring down console type changemap map04, load up the new map, open the first door to get to the first bunch of enemies next to the shutters, face the shutters at any angle and die, boom the 2nd screenshot i showed you.

I'll even get a video of it if need be.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Lookers [Update 12/7/21]

Post by Hey Doomer »

thugsta wrote: Weird :?: :shock: I literally had nothing else loaded other then your tweak (hell even disabled reshade to test just in case). Sure the first screenshot is on me forgetting to isolate the problem with the new addon if there was a conflict but the second screenshot when loaded with this single tweak i could reproduce it over and over again. I hammer enter to start a new game asap, bring down console type changemap map04, load up the new map, open the first door to get to the first bunch of enemies next to the shutters, face the shutters at any angle and die, boom the 2nd screenshot i showed you.

I'll even get a video of it if need be.
See the updated file. I removed Lookers for Death and XDeath states.
thugsta
Posts: 150
Joined: Mon Jan 21, 2019 10:10 am

Re: Lookers [Update 12/7/21]

Post by thugsta »

Hey Doomer wrote:
See the updated file. I removed Lookers for Death and XDeath states.
Still does it but i have found by playing with the options on what causes it. Having 'Enable Autosaves to Always" in Miscellaneous Settings. Turning this off made it not crash anymore, first time i have seen the engines own autosave bother a mod.
Hope this can make you now get to the bottom of the problem.

Return to “Script Library”