Prevent "underwater actors" from moving out of the water?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Prevent "underwater actors" from moving out of the water?

Post by Tormentor667 »

Another nooby-question I guess: I am using Sharks in BoA that can fly but should not be able to leave the 3d water sectors. How can I prevent them to do this? Or are there any other flags for "swimming in water sectors"?
User avatar
Hellser
Global Moderator
Posts: 2706
Joined: Sun Jun 25, 2006 4:43 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Citadel Station

Re: Prevent "underwater actors" from moving out of the water

Post by Hellser »

Hm. There are checks to see if an actor is underwater, but not "keep an actor IN the water" -- could be a feature request?
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Nash »

I'm interested in this too. Would appreciate it if someone posted a bare-bones example. I see MaxEd achieved this in his Powerslave mod but the WAD is too large-scope for me to quickly inspect (yeah I'm impatient LOL).
User avatar
Zanieon
Posts: 2059
Joined: Tue Jan 13, 2009 4:13 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Somewhere in the future
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Zanieon »

in ACS:

Code: Select all

Script "WaterLevelCheck" (Void)
{
	While (TRUE)
	{
		if ( GetActorProperty (0, APROP_Waterlevel) < 3 && GetUserVariable(0, "user_isswimming")==1 )
			SetActorState(0, "Swim.Cancel");
		else if ( GetActorProperty (0, APROP_Waterlevel) == 3 && GetUserVariable(0, "user_isswimming")==0 )
			SetActorState(0, "Swim.Allow");
		Delay(1);
	}
}
in DECORATE:

Code: Select all

ACTOR Somerandomshitthatswims
{
	var int user_isswimming;

	States:
	{
	Swim.Cancel:
		TNT1 A 0 A_ChangeFlag("FLOAT",0)
		TNT1 A 0 A_ChangeFlag("NOGRAVITY",0)
		TNT1 A 0 A_SetUserVar("user_isswimming",0)
		Goto See
	Swim.Allow:
		TNT1 A 0 A_ChangeFlag("FLOAT",1)
		TNT1 A 0 A_ChangeFlag("NOGRAVITY",1)
		TNT1 A 0 A_SetUserVar("user_isswimming",1)
		Goto See
	}
}
I didn't tested, write this right now, but the idea is something like this.
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

There is also a much more easy way to fix sharks without using acs. Just give me ten mins and I'll post here.
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

Here you are: add MaxStepHeight 1 to properties. I wasn't on my PC for a while :-)

[EDIT]: I see you've add a missile state inside shark, now I know exactly why you needed it... :roll:
Nevermind above stuff.
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

Nash wrote:I'm interested in this too. Would appreciate it if someone posted a bare-bones example. I see MaxEd achieved this in his Powerslave mod but the WAD is too large-scope for me to quickly inspect (yeah I'm impatient LOL).
That's the MaxED piranha code, it has some actors inheritances here and there, but everyhting is here.
Spoiler:
User avatar
Zanieon
Posts: 2059
Joined: Tue Jan 13, 2009 4:13 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Somewhere in the future
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Zanieon »

The problem there Ozymandias81, the delay to check if the actor is under water is too long and causes a bit of "jumping" out of the water, this behavior is the intention on this mainly because a piranha really behaves as this unlike a shark that stays underwater more often, reducing the check delay on the state would solve the problem but this will go make piles of extra lines in the decorate which isn't necessary if there is a script is running on background to do the job it.

Well decision is up to Torm on what code use, both solves the problem i think (as i said above, i didn't tested mine)
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

Revilution wrote:The problem there Ozymandias81, the delay to check if the actor is under water is too long and causes a bit of "jumping" out of the water, this behavior is the intention on this mainly because a piranha really behaves as this unlike a shark that stays underwater more often, reducing the check delay on the state would solve the problem but this will go make piles of extra lines in the decorate which isn't necessary if there is a script is running on background to do the job it.

Well decision is up to Torm on what code use, both solves the problem i think (as i said above, i didn't tested mine)
I'm OK with you Rev, I tried some odd stuff to see if running continuosly thingthrust while underwater could help, but didn't work unless we have only melee states in it (I mean the shark).
The fact is that I have a piranha inside Gore that works exactly like shark one, except that it doesn't have any missiles states that will prevent it to go out of water.
BTW I'll try now your code and if it works I'll ask to Torm to implement on sharks.
Thankx anyway Rev (I'm gonna give a look to your big boss and see if I'm skilled enough to to make/change its not-so-doomish palette into a baron one).
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

While I wasn't capable to implement Rev's code, I've done a silly trick that worked a bit.
Here's the shark code, the trick can be found inside "missile" state:
Spoiler:
Inspired to maulerdemon attack, the shark can't fly out the water sector, it just "jumps" sometimes like a swimming player.

@Torm
If it works, may I add this stuff?
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Nash »

TBH (and no offense) this is all really hacky shit and it really should be just be an engine-side flag like +CANTLEAVEWATER or something like that. :S
User avatar
Zanieon
Posts: 2059
Joined: Tue Jan 13, 2009 4:13 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Somewhere in the future
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Zanieon »

Hellser wins the match then, lol
User avatar
Ozymandias81
Posts: 2063
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Ozymandias81 »

@nash
Exactly the same I had in my mind while losing time with it :roll:

@revilution
Definately :lol: :bang: :lol:
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Tormentor667 »

Nash wrote:TBH (and no offense) this is all really hacky shit and it really should be just be an engine-side flag like +CANTLEAVEWATER or something like that. :S
Yep, I am just gonna request that :)
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: Prevent "underwater actors" from moving out of the water

Post by Tormentor667 »

http://forum.zdoom.org/viewtopic.php?f= ... 88#p823288
Actually not solvable, so we need to continue hacking around -_-
Locked

Return to “Editing (Archive)”