There's a command called SET_MORELIGHT that changes NPCs light value to 96 when it is true (makes them brighter). I want to replicate the same command but for player character. This command is intended to adjust the brightness of player characters dynamically, similar to how the SET_MORELIGHT command works for NPCs (It works only for SP Mode).
The command should:
- Be callable from the in-game console or a .cfg file
- Toggle a moreLight property for the player entity
- Adjust the player's brightness in the game by increasing their minlight value when moreLight is enabled.
What I've tried so far:
1. modified entityState_s:
typedef struct entityState_s {
// ...
qboolean moreLight;
// ...
}
2. Updated MSG_WriteDeltaEntity and MSG_ReadDeltaEntity to include the moreLight property. I also added an entry for moreLight in the entityStateFields array:
netField_t entityStateFields[] = {
// ...
{ NETF(moreLight), 1 },
// ...
}
3. Added the SET_MORELIGHT_PLAYER command to CQuake3GameInterface::Set and mapped it in the setTable array:
stringID_table_t setTable[] = {
// ...
ENUM2STRING(SET_MORELIGHT_PLAYER),
// ...
}
Here's the command in CQuake3GameInterface::Set:
void CQuake3GameInterface::Set( int taskID, int entID, const char *type_name, const char *data ) {
// ...
switch ( toSet ) {
// ...
case SET_MORELIGHT_PLAYER:
Quake3Game()->DebugPrint(IGameInterface::WL_DEBUG, "SET_MORELIGHT_PLAYER triggered with value %s\n", data);
if (!Q_stricmp("true", ((char*)data))) {
Q3_SetMoreLightPlayer(entID, qtrue);
}
else {
Q3_SetMoreLightPlayer(entID, qfalse);
}
break;
}
}
4. I wrote the Q3_SetMoreLightPlayer function to toggle the moreLight flag for the player:
static void Q3_SetMoreLightPlayer(int entID, qboolean add) {
gentity_t *ent = &g_entities[entID];
if (!ent || !ent->client) {
Quake3Game()->DebugPrint(IGameInterface::WL_WARNING, "Invalid entity or not a player!\n");
return;
}
ent->s.moreLight = add;
Quake3Game()->DebugPrint(IGameInterface::WL_DEBUG, "Player moreLight set to: %d\n", ent->s.moreLight);
}
5. I added logic to check ent->s.moreLight and increase the minlight value for the player:
if (ent->s.moreLight) {
cgi_R_AddLightToScene(ent->currentOrigin, 96, 1.0, 1.0, 1.0);
}
6. Created .cfg files to toggle the feature:
set_morelight_player.cfg:
set ( "SET_MORELIGHT_PLAYER", "true" );
echo "SET_MORELIGHT_PLAYER has been activated.";
set_morelight_player_off.cfg:
set ( "SET_MORELIGHT_PLAYER", "false" );
echo "SET_MORELIGHT_PLAYER has been deactivated.";
Issues
The Command Doesn’t Trigger the Functionality:
When I execute exec set_morelight_player, I see the echo statement from the .cfg file, but the debug prints in CQuake3GameInterface::Set or Q3_SetMoreLightPlayer do not appear.
Direct Console Command Doesn’t Work:
Executing set ( "SET_MORELIGHT_PLAYER", "true" ); directly in the console doesn’t seem to do anything.
Rendering Logic Doesn’t Respond:
Even if ent->s.moreLight is toggled successfully, I don’t see any visible change in the player’s brightness.
I am new to modding so I will appreciate an explanation of what should I do, given someone who knows what to do sees this post.
Thank you very much
May the Force be with you!