Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Kewun on Sep 11, 2016, 06:19 PM

Title: on Player Is InWater function
Post by: Kewun on Sep 11, 2016, 06:19 PM
I dont have any idea how to do the function onPlayerIsInWater

this is called if player is drowning in the water  " swimming like"

anyone help me ?
Title: Re: on Player Is InWater function
Post by: vito on Sep 11, 2016, 06:23 PM
maybe check his Pos.z (exclude one area in the little havana)
Title: Re: on Player Is InWater function
Post by: Kewun on Sep 11, 2016, 06:24 PM
well i trought about that
but there is many water places and im lazy to put all pos's ;c
Title: Re: on Player Is InWater function
Post by: vito on Sep 11, 2016, 10:11 PM
Water level is same for whole map, just few places below water (I know only one actually). So you need to make an exception in the code and all be fine.
Try also to test http://wiki.vc-mp.org/wiki/OnPlayerActionChange action's list is not documented anywhere so I don't know maybe you will find something about water there.
Title: Re: on Player Is InWater function
Post by: . on Sep 11, 2016, 10:15 PM
Quote from: vito on Sep 11, 2016, 10:11 PMaction's list is not documented anywhere so I don't know maybe you will find something about water there.

There isn't. (https://github.com/iSLC/VCMP-SqMod/blob/master/source/SqBase.hpp#L643) Although, I'm not sure if they've added any new ones. I'm always behind on these things so don't take my word for it.
Title: Re: on Player Is InWater function
Post by: aXXo on Sep 13, 2016, 07:20 PM
Should be achievable with Ray Tracing
Trace a ray between ( player.Pos.X, player.Pos.Y, player.Pos.Z + 5) and ( player.Pos.X, player.Pos.Y, -10 ) with flags only detecting collisions with objects and buildings.

Check the entity it collides with.
If the entity is Sea bed, coastal rocks or some submerged ship means the player is in or hovering above water.

Though, vito's suggestion is also reliable and easier to implement.
Title: Re: on Player Is InWater function
Post by: Murdock on Sep 13, 2016, 08:26 PM
I believe there's an internal function in VC for this that returns whether the player is in water, but it would need the devs to sync that flag and add it as attribute to the squirrel plugin (player.InWater, vehicle.InWater, object.InWater)

If any devs are alive willing to look into this, here are the OPcodes for the functions:
04AD IS_CHAR_IN_WATER
0521 IS_CHAR_DROWNING_IN_WATER
02BF IS_CAR_IN_WATER
04E7 IS_OBJECT_IN_WATER
Title: Re: on Player Is InWater function
Post by: Kewun on Sep 14, 2016, 03:15 AM
Quote from: aXXo on Sep 13, 2016, 07:20 PMShould be achievable with Ray Tracing
Trace a ray between ( player.Pos.X, player.Pos.Y, player.Pos.Z + 5) and ( player.Pos.X, player.Pos.Y, -10 ) with flags only detecting collisions with objects and buildings.

Check the entity it collides with.
If the entity is Sea bed, coastal rocks or some submerged ship means the player is in or hovering above water.

Though, vito's suggestion is also reliable and easier to implement.

what is ray tracing? i never know
Title: Re: on Player Is InWater function
Post by: vito on Sep 14, 2016, 07:05 AM
Quote from: Kewun on Sep 14, 2016, 03:15 AMwhat is ray tracing? i never know
Its like a virtual bullet shotted from Vector#1 to Vector#2. If it will hit something between #1 and #2 you can read what and where.
Title: Re: on Player Is InWater function
Post by: Kewun on Sep 14, 2016, 01:37 PM
i dont know how.. maybe a little example ? ;c
Title: Re: on Player Is InWater function
Post by: Kewun on Sep 15, 2016, 07:18 PM
so a timer which checks player.Pos.z if i understand good

ill try then

edit: forgot about onPlayerMove il try that too
Title: Re: on Player Is InWater function
Post by: EK.IceFlake on Sep 16, 2016, 09:28 AM
Check his animation if it is drowning animation == he is in water