Page 1 of 1

New world weapon API

Posted: Tue Jun 19, 2018 12:56 am
by Zehra
The world weapon API has changed a lot.

bz_fireWorldGM ( int targetPlayerID, float lifetime, float *pos, float tilt, float direction, float dt , bz_eTeamType shotTeam = eRogueTeam );
Parameters

Code: Select all

name 	                type 	       value description
targetPlayerID 	          int 	       Player to fire the GM at.
lifetime 	         float 	       How long the world weapon will "live".
*pos 	                 float 	       Position the world weapon will fire from.
tilt 	                 float 	       The tilt of the weapon in radians.
direction 	         float 	       The direction of which to fire the world weapon in radians. (rotation)
dt 	                 float 	       Delay time. How many seconds the weapon waits before firing.
shotTeam 	         bz_eTeamType 	Team color of the weapon. (Rogue by default) 
fireWorldWep ( const char* flagType, float lifetime, int fromPlayer, float *pos, float tilt, float direction, int *shotID , float dt , bz_eTeamType shotTeam = eRogueTeam );
Parameters

Code: Select all

name 	            type 	                value description
flagType 	    const char* 	        Flag type the world weapon will fire with
lifetime 	    float 	                How long the world weapon will "live".
fromPlayer          int 	                Player ID that fired the shot, or BZ_SERVER.
*pos 	            float                  	Position the world weapon will fire from.
tilt 	            float 	                The tilt of the weapon in radians.
direction 	    float 	                The direction of which to fire the world weapon in radians. (rotation)
shotID 	            int                         Shot ID of the world weapon.
dt 	            float 	                Delay time. How many seconds the weapon waits before firing.
shotTeam 	    bz_eTeamType 	     Team color of the weapon. (Rogue by default) 
The newer version uses this:
bz_fireServerShot(const char* shotType, float origin[3], float vector[3], bz_eTeamType color = eRogueTeam, int targetPlayerId = -1);

How would I convert both versions to the newer version of the API?
(I would like to be able to update these two custom flag plug-ins SnakeShots and CustomFlags.)

-Zehra

Re: New world weapon API

Posted: Wed Jun 20, 2018 1:40 am
by allejo
Take a look at how core BZFlag plugins were updated to the new API and an overview of how to use the new API.

Narrow down your question to something more specific.

Re: New world weapon API

Posted: Wed Jun 20, 2018 4:49 am
by JeffM
The new function mostly ignores some arguments and takes a vector instead of 2 angles.

The utility function
bz_vectorFromRotations(const float tilt, const float rotation, float outVec[3])

Is provided for developers who don’t know basic trigonometry.

Re: New world weapon API

Posted: Wed Jun 20, 2018 8:35 pm
by Zehra
Thank you JeffM and allejo.

Was able to get custom flags updated. :)

-Zehra