Page 1 of 1

[WIP] Spectator Utility Library

Posted: Wed Feb 07, 2018 1:26 am
by ibm5155
Heh, zandronum doesn't have Zscript yet but we got SUL :biggrin:
And also Thanks Torr.

Download V1.1
Spoiler: old versions (Open)
After years of research I'm here to present you the Spectator Utility Library (SUL), SUL is a packet of scripts that will help you to Interact with spectators, with that you can do stuff like knowing the coord from where the spectators are looking at, check if the spectator is looking to an object and what's his distance from that object,...

The Project is broken in 3 sub projects:
>SpecUtil : The main library with the minimal required files to get information from spectators.
>SpecExample_1.0: An example mod with build in code to demonstrate some of the use cases of SpecUtil, some of those are:
--Rendering where the spectators are ingame.
--Showing who's watching you (coop spy) [limited to only show the spectators that are watching you but it could be expanded]
>DumbTid: This is a simple wad that sets the players a tid, this is only needed in case you want to run SpecExample with a mod or no mods where it doesn't set the players tid.

Here's an example of SpecExample in action (not as perfect as it's right now)
https://www.youtube.com/watch?v=UZ8o0f20ldU
In Knuckles Horde I used SUL for:
-Rendering the spectators (black transparente balls)
-Rendering the Knuckles (since weapons skin cannot have 3D models :( )
-Adding Dead animation to knuckles.
-Showing who's watching you.

-----------------------------------------------------------------------

Q: I want to Modify or Add those files inside of my mod, am I allowed to do that?
A: Yes, feel free to do what you desire with this mod.

Q:How do I include the SpecUtil to use with my wad?
A: You just don't, all you need is to write this :

Code: Select all

int SpecZ = ACS_NamedExecuteWithResult("GetConsolePlayerCameraZ");
if you have loaded the SpecUtil pk3 file OR you have added the acs lib file inside your acs folder and added his name into loadacs, it should be working just fine.
If SUL wasn't loaded then it'll show an error messagel like script GetConsolePlayerCameraZ wasn't found.

Q:Why scripts with return and not functions
A: Because of
-I wanted to force everyone to use the SOL code in clientside only code.
-So you could make decorate objects that could interact with the SOL "functions" without the need of adding new acs code.

[WIP] Re: Spectator Utility Library

Posted: Thu Feb 08, 2018 12:49 am
by ibm5155
Function List From SpecUtil V1.0:

Code: Select all

-GetConsolePlayerCameraX: 
//USAGE:
// Get the X view Coord from the activator, this way you can find where the activator is looking at
//RETURN:
// (FIXED POINT) X Coord

-GetConsolePlayerCameraY: 
//USAGE:
// Gets  the Y view Coord from the CONSOLEPLAYER, this way you can find where the CONSOLEPLAYER is looking at
//RETURN:
// (FIXED POINT) Y Coord

-GetConsolePlayerCameraZ: 
//USAGE:
// Get the Z view Coord from the CONSOLEPLAYER, this way you can find where the CONSOLEPLAYER is looking at
//RETURN:
// (FIXED POINT) Z Coord

-GetConsolePlayerCameraAngle: 
//USAGE:
// Gets the the angle Coord from the CONSOLEPLAYER, this way you can find where the angle that CONSOLEPLAYER is looking
//RETURN:
// (FIXED POINT ANGLE) Pitch

-GetConsolePlayerCameraPitch: 
//USAGE:
// Get the the Pitch Coord from the CONSOLEPLAYER, this way you can find where the Pitch that CONSOLEPLAYER is looking
//RETURN:
// (FIXED POINT PITCH) Pitch

-CheckConsolePlayerCloser (int Distance, bool check 2D)
//USAGE:
// Check if the object who called this script (the activator) is closer to the CONSOLEPLAYER
//INPUT:
// Distance: (INTEGER) the max distance that the activator should be from the CONSOLEPLAYER
// Check_2D: (BOOL) 1 if you want to ignore the z coord, 0 if you want to also check the z coord
//RETURN:
// (BOOL) 1 if the Activator is closer to the clientside player, else 0.

-GetConsolePlayer_VectorAngleWithTid (Tid)
//USAGE:
// Check the angle formed by the CONSOLEPLAYER (being the center) with a given Tid
//INPUT:
// Tid: (TID) The Tid to be checked
//RETURN:
// (FIXED POINT ANGLE) Angle

-CheckifConsolePlayerLOS (Tid, LOS Angle)
//USAGE:
// Check if the CONSOLEPLAYER is in Line of Sight with a given Tid.
//INPUT:
// CheckTid: (TID) the Tid of the object to be checked
// fixed_point_angle: (FIXED POINT ANGLE) the left/right angle offset that the player should be looking at the center of the Object.
//RETURN: 
// (bool) 1 if the player is in LOS with the object, else 0.
//WARNING: 
// THIS function doesn't check for walls

[WIP] Re: Spectator Utility Library

Posted: Thu Feb 08, 2018 8:40 pm
by Fused
Really well done. This can prove very useful when making clientsided effects.

[WIP] Re: Spectator Utility Library

Posted: Thu Feb 08, 2018 10:10 pm
by Samuzero15tlh
Pretty useful!, NOW its possible to make spectator ghosts, cant wait to use this, good job!

[WIP] Re: Spectator Utility Library v1.1 Released

Posted: Sat Feb 10, 2018 7:15 pm
by ibm5155
Download V1.1

Ok here's a small but interesting update from SpecUtil and Spec Example kit:

-SpecUtil:
--3 New functions added (GetConsolePlayerX, GetConsolePlayerY, GetConsolePlayerZ)

-SpecExample:
--Now you do not need the DumbTid to work with maps that doesn't set the player tid
--You can now also see the players that are watching you not only the spectators
--set a player tid in case the existing mods doesn't that
--Simplified code so now the server side only send requests from the clients.
--whos watching you font is now smaller.

New Functions in SpecUtil V1.1

Code: Select all

-GetConsolePlayerX
//USAGE:
// Get the X Coord from the activator, this way you can find where the activator is
//RETURN:
// (FIXED POINT) X Coord
    if(SetActivatorToPlayer(ConsolePlayerNumber()) == 0){
		print(s:"Error in SetActivatorToPlayer, return 0");
    }	
    SetResultValue(GetActorX(0));
}

-GetConsolePlayerY
//USAGE:
// Get the Y Coord from the activator, this way you can find where the activator is
//RETURN:
// (FIXED POINT) Y Coord
    if(SetActivatorToPlayer(ConsolePlayerNumber()) == 0){
		print(s:"Error in SetActivatorToPlayer, return 0");
    }	
    SetResultValue(GetActorY(0));
}

-GetConsolePlayerZ
//USAGE:
// Get the Z Coord from the activator, this way you can find where the activator is
//RETURN:
// (FIXED POINT) Z Coord
    if(SetActivatorToPlayer(ConsolePlayerNumber()) == 0){
		print(s:"Error in SetActivatorToPlayer, return 0");
    }	
    SetResultValue(GetActorZ(0));
}
SpecExample 1.1 was tested with the following mods:
-Jump Maze
-Zombie Horde + Addons
-Vanilla Doom
-Who Dun It

[WIP] Re: Spectator Utility Library

Posted: Tue Feb 13, 2018 12:54 am
by Ænima
Sweeeeet.

Good job, ibm. :)