7
6
Fork
You've already forked Unvanquished
1

Proposal: add a "library" to manipulate basic gameplay elements more easily #36

Open
opened 2026年01月15日 18:11:30 +01:00 by bmorel · 0 comments

Since a few months, I have a growing set of functions that allow to query gameplay stuff less verbosely, and which I try to make both cgame and sgame compatible (not always possible yet but when I'll have been gotten rid of CBSE, they will).
I keep the main "lib" C-style, for various reasons, but am going to have a few classes as well (notably an iterator that does not relies on CBSE), which will live in their own headers, all is self-contained.
I believe it would help everyone.

For now, it only provides those helpers:

sgame:

bool G_IsDead( gentity_t const& ent );
bool G_IsAlive( gentity_t const& ent );
unsigned G_MaxHealth( gentity_t const& ent );
bool G_IsEnemy( gentity_t const& ent1, gentity_t const& ent2 );
bool G_IsEnemy( team_t t1, gentity_t const& ent2 );
bool G_IsAlly( gentity_t const& ent1, gentity_t const& ent2 );
bool G_IsAlly( team_t t1, gentity_t const& ent2 );

both games:

bool BG_IsMiner( entityState_t const& es );
bool BG_IsMiner( buildable_t type );
bool BG_BoundingBox( missile_t, glm::vec3& mins, glm::vec3& maxs );
bool BG_BoundingBox( buildable_t, glm::vec3& mins, glm::vec3& maxs );
bool BG_BoundingBox( class_t, glm::vec3& mins, glm::vec3& maxs );
glm::vec3 BG_CrouchMaxs( class_t pClass );
glm::vec3 AnglesToForward( playerState_t const& ps );
trace_t RayTrace( glm::vec3 const& origin
 , glm::vec3 direction // passed by value as will be modified anyway
 , int passEntityNum
 , int contentmask
 );
const classAttributes_t* BG_Class( playerState_t const* ps );
const weaponAttributes_t* BG_Weapon( playerState_t const* ps );
bool BG_HaveBuildWeapon( playerState_t const& ps );

This is a work in progress, so it's not yet perfectly consistent, but here are a few notes:

  • I use a C-style API so that it does not slows down build times;
  • playerState_t and entityState_t are the most used structures, as they are shared between cgame and sgame;
  • some functions I have are not in that list because they live in other branches and I have not yet sorted everything out (such as unsigned G_Health( entityState_t const& );
  • this stuff lives in it's own folder, to reduce risk of git conflict as much as is possible. It's included like: include <mods/mods_api.h> for example;
  • when I will be done with some of my personal goals, it will be much richer, and will allow to query the gameplay instead of hard-coding things (especially useful for bots);

This issue is mostly to ask for feedback: interested or not? If interested, any suggestions?

Since a few months, I have a growing set of functions that allow to query gameplay stuff less verbosely, and which I try to make both cgame and sgame compatible (not always possible *yet* but when I'll have been gotten rid of CBSE, they will). I keep the main "lib" C-style, for various reasons, but am going to have a few classes as well (notably an iterator that does not relies on CBSE), which will live in their own headers, all is self-contained. I believe it would help everyone. For now, it only provides those helpers: sgame: ``` bool G_IsDead( gentity_t const& ent ); bool G_IsAlive( gentity_t const& ent ); unsigned G_MaxHealth( gentity_t const& ent ); bool G_IsEnemy( gentity_t const& ent1, gentity_t const& ent2 ); bool G_IsEnemy( team_t t1, gentity_t const& ent2 ); bool G_IsAlly( gentity_t const& ent1, gentity_t const& ent2 ); bool G_IsAlly( team_t t1, gentity_t const& ent2 ); ``` both games: ``` bool BG_IsMiner( entityState_t const& es ); bool BG_IsMiner( buildable_t type ); bool BG_BoundingBox( missile_t, glm::vec3& mins, glm::vec3& maxs ); bool BG_BoundingBox( buildable_t, glm::vec3& mins, glm::vec3& maxs ); bool BG_BoundingBox( class_t, glm::vec3& mins, glm::vec3& maxs ); glm::vec3 BG_CrouchMaxs( class_t pClass ); glm::vec3 AnglesToForward( playerState_t const& ps ); trace_t RayTrace( glm::vec3 const& origin , glm::vec3 direction // passed by value as will be modified anyway , int passEntityNum , int contentmask ); const classAttributes_t* BG_Class( playerState_t const* ps ); const weaponAttributes_t* BG_Weapon( playerState_t const* ps ); bool BG_HaveBuildWeapon( playerState_t const& ps ); ``` This is a work in progress, so it's not yet perfectly consistent, but here are a few notes: * I use a C-style API so that it does not slows down build times; * `playerState_t` and `entityState_t` are the most used structures, as they are shared between cgame and sgame; * some functions I have are not in that list because they live in other branches and I have not yet sorted everything out (such as `unsigned G_Health( entityState_t const& )`; * this stuff lives in it's own folder, to reduce risk of git conflict as much as is possible. It's included like: `include <mods/mods_api.h>` for example; * when I will be done with some of my personal goals, it will be much richer, and will allow to query the gameplay instead of hard-coding things (especially useful for bots); This issue is mostly to ask for feedback: interested or not? If interested, any suggestions?
Sign in to join this conversation.
No Branch/Tag specified
unvmods-0.56
map-testing-0.56.0-14
spawn-clear-ui-sweet
spawn-clear-ui
unvmods-biokit
map-testing-0.56.0-13
deadbeef-mover-fixes
map-testing-0.56.0-12
map-testing-0.56.0-11
map-testing-0.56.0-10
map-testing-0.56.0-9
unvmods-0.56-mods-space-brawl-ok
deadbeef-spinigun
map-testing-0.56.0-8
unvmods-0.56-fix-ps-stats
unvmods-0.56-no-__DATE__
unvmods-readme-update
unvmods-0.56-bugfixes
chaingun-overheat
bunker-0.56.0-0
entity-cache-robustness
unvmods-0.56-deadbeef-pending
map-testing-0.56.0-7
map-testing-0.56.0-7-lua-bsp-nodes
bunker-0.56.0-rtm
bunker-0.56.0-rc2
bunker-0.55.3-4
kench-stacking-0.55.5
bunker-0.55.3-3
bunker-0.55.3-2-sm2
unvmods-0.56-bot-menu
unvmods-0.56-stack-buildings-dirty
unvmods-0.56-rotator-obstacle
deadbeef-0.56-fix-server-version
bunker-0.55.3-2
g_admin_crash
unvmods-gdb-stack-trace
unvmods-stack-traces
bunker-0.55.3-1
zzz_enneract
grise-patch-1
bunker-0.55.3-0
chainturbations-fix
bunker-0.55.2-0
master
unvmods-0.56.0-0
v0.55.2
unvanquished/0.55.2
v0.55.1
unvanquished/0.55.1
v0.55.0
unvanquished/0.55.0
v0.54.1
unvanquished/0.54.1
v0.54.0
unvanquished/0.54.0
v0.53.2
unvanquished/0.53.2
v0.53.1
unvanquished/0.53.1
v0.53.0
unvanquished/0.53.0
unvanquished/0.52.1
v0.52.1
v0.52.0
unvanquished/0.52.0
anyteam_3
anyteam_2
anyteam_1
v0.51.2
archlinux/0.51.1-1
v0.51.1
unvanquished/0.51.1
archlinux/0.51.2-1
v0.51.0
v0.50.0
archlinux/0.50.0-2
archlinux/0.50.0-1
v0.49.0
archlinux/0.49.0-1
v0.48.0
archlinux/0.48.0-1
v0.47.0
archlinux/0.47.0-1
devgame/20151227
devgame-20151220
devgame-20151219
v0.46.0
archlinux/0.46.0-1
v0.45.0
archlinux/0.45.0-1
v0.44.0
archlinux/0.44.0-2
archlinux/0.44.0-1
v0.43.1
v0.43.0
archlinux/0.43.0-1
v0.42.0
archlinux/0.42.0-1
v0.41.0
archlinux/0.41.0-1
archlinux/0.40.0-1
v0.40.0
v0.39.0
archlinux/0.39.0-2
archlinux/0.39.0-1
v0.38.0
archlinux/0.38.0-1
devgame/20150322
devgame/20150315
devgame/20150308
archlinux/0.37.0-1
v0.37.0
devgame/20150222
devgame/20150215
devgame/20150208
v0.36.0
archlinux/0.36.0-1
devgame/20150118
devgame/20150111
v0.35.1
v0.35.0
archlinux/0.35.1-1
archlinux/0.35.0-1
archlinux/0.34.0-2
archlinux/0.34.0-1
v0.34.0
v0.33.1
archlinux/0.33.1-1
v0.33.0
archlinux/0.33.0-1
v0.32.0
archlinux/0.32.0-1
v0.31.0
archlinux/0.31.0-1
devgame/20140831
v0.30.0
archlinux/0.30.0-1
devgame/20140720
debian/0.29.0-2
debian/0.29.0-1
v0.29.0
archlinux/0.29.0-1
devgame/20140622
devgame/20140615
devgame/20140608
v0.28.0
archlinux/0.28.0-2
archlinux/0.28.0-1
devgame/20140601
archlinux/0.27.2-3
devgame/20140518
debian/0.27.2-1
archlinux/0.27.2-2
archlinux/0.27.2-1
v0.27.2
0.27.1-1-deb
v0.27.1
0.27.0-1-deb
0.27.0-1-arch
v0.27.0
0.26.0-1-arch
v0.26.0
0.25.0-2-deb
0.25.0-1-arch
v0.25.0
0.25.0-1-deb
0.24.1-1-arch
v0.24.1
0.24.0-4-deb
0.24.0-4-arch
0.24.0-3-arch
0.24.0-2-arch
v0.24.0
0.24.0-2-deb
0.24.0-1-deb
devgame/20140201
devgame/20140126
devgame/20140125
devgame/20140119
0.23.0-2-deb
devgame/20140118
devgame/20140112
v0.23.0
0.23.0-1-deb
devgame/20131229
devgame/20131222
0.22.1-2-deb
0.22.1-1-deb
v0.22.1
0.22.0-1-deb
v0.22.0
devgame/20131124
devgame/20131117
devgame/20131110
0.21.0-2-deb
0.21.0-1-deb
v0.21.0
devgame/20131027
0.20.0-3-deb
0.20.0-2-deb
0.20.0-1-deb
devgame/20131006
v0.20.0
0.19.0-2-deb
devgame/20130922
devgame/20130915
0.19.0-1-deb
v0.19.0
0.18.0-2-deb
last-frags-stages
2013-summer-tourney-0.18.0
0.18.0-1-deb
v0.18.0
devgame/20130713
2013-summer-tourney
v0.17.0
last-gameplay-map-control
0.16.0-1-deb
v0.16.0
0.15.0-1-deb
v0.15.0
v0.14.0-last-compat
0.14.0-1-deb
v0.14.0
fix/colorgrading
refactor/configfiles
0.13.1-1-deb
v0.13.1
0.13.0-1-deb
feature/vistest
v0.13.0
0.12.0-2-deb
feature/teambinds
0.12.0-1-deb
v0.12.0
feature/motionblur
0.11.0-2-deb
v0.11.0
0.10.0-3-deb
0.10.0-2-deb
0.10.0-1-deb
v0.10.0
0.9.0-2-deb
0.9.0-1-deb
v0.9.0
0.8.0-1b1-deb
0.8.0-1b1
0.8.0-1-deb
v0.8.0
v0.7.0-last-compat
0.7.0-1-deb
v0.7.0
v0.6.0-last-compat
0.6.0-3
0.6.0-2-deb
0.6.0-1-deb
v0.6.0
v0.5.1-last-compat
0.5.1-1-deb
v0.5.1
0.5.0-2-deb
0.5.0-1-deb
v0.5.0
v0.4.0-last-compat
0.4.0-2-deb
0.4.0-1-deb
v0.4.0
v0.4.0-last-compat-0.3.5
0.3.5-3-deb
0.3.5-2-deb
0.3.5-1-deb
0.3.5-0-deb
v0.3.5
0.3.0-2-deb
0.3.0-1-deb
v0.3.0
0.2.5-4-deb
0.2.5-3-deb
0.2.5-2-deb
0.2.5-deb
No labels
bug
regression
upstream
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
unvmods/Unvanquished#36
Reference in a new issue
unvmods/Unvanquished
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?