Raised This Month: $ Target: $400
 0% 

Water Physics?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 06-16-2010 , 22:48   Water Physics?
Reply With Quote #1

How would I make it so clients move around as if they were in water, when they actually aren't submerged in any?

Also, although less necessary, how would I do the same for props?
__________________
almcaeobtac is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 06-16-2010 , 22:58   Re: Water Physics?
Reply With Quote #2

Theres an FL_INWATER entity flag. Maybe try setting the flag OnPlayerRunCmd() or in an SDK Hooks think hook.
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 06-17-2010 , 00:15   Re: Water Physics?
Reply With Quote #3

And, you have SdkHooks with StartTouch and EndTouch hooks for props (water is a worldspawn)
miniman is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-17-2010 , 06:53   Re: Water Physics?
Reply With Quote #4

i've only briefly tested this, the prop "m_nWaterLevel" stores how far above/under the water surface a player is, its used for stuff like drowning, i managed to drown myself on dry land.

from the source sdk
PHP Code:
not in water (WL_NotInWater)
feet in water (WL_Feet)
waist in water (WL_Waist)
head in water (WL_Eyes
also theres "m_nWaterType"
PHP Code:
none
water
slime 
blodia is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 06-17-2010 , 08:19   Re: Water Physics?
Reply With Quote #5

If you're simply looking for a way to "float" about in air (still affected by gravity and collides), you can just set the entity's movetype

http://docs.sourcemod.net/api/index....d=show&id=848&

The comments also have the different types of movement.
Monkeys is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 06-19-2010 , 15:36   Re: Water Physics?
Reply With Quote #6

Quote:
Originally Posted by meng View Post
Theres an FL_INWATER entity flag. Maybe try setting the flag OnPlayerRunCmd() or in an SDK Hooks think hook.
How though?
__________________
almcaeobtac is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 06-20-2010 , 16:02   Re: Water Physics?
Reply With Quote #7

You shouldnt need to set it in OnPlayerRunCmd, just add it to the m_fFlags prop using SetEntProp(ent, Prop_Send, "m_fFlags", FL_INWATER);
There is a chance that the game will re-evaluate this and remove it on the next frame if the player isn't in water. You'll have to find out for yourself by printing the values somewhere so you can compare them.
Wazz is offline
iloveportalz0r
Member
Join Date: May 2010
Location: Up yours
Old 06-21-2010 , 22:59   Re: Water Physics?
Reply With Quote #8

Quote:
Originally Posted by blodia View Post
i managed to drown myself on dry land.
Can you post the code please?
__________________
I sure was dumb in 2010
iloveportalz0r is offline
almcaeobtac
Senior Member
Join Date: Nov 2008
Location: Florida
Old 06-21-2010 , 23:33   Re: Water Physics?
Reply With Quote #9

I got that too, I used

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnClientPutInServer(Client)
{
	SDKHook(Client, SDKHook_PreThink, PreThinkEvent);
}

public PreThinkEvent(Client)
{
	SetEntProp(Client, Prop_Send, "m_nWaterLevel", 3);
}
Also, it's still not working. The player can drown, but can't swim.
__________________
almcaeobtac is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode