Jump to content

SET_MORELIGHT command but for player character


Recommended Posts

Posted

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!

Posted

I think the mistake is that you're trying to call it from a cfg file. Commands called in the Q3_Interface class need to be called through an IBI script, which you can create with BehavED.

I'm not noticing any issues in your code.

To help you get started with setting up BehavED, I wrote a tutorial that get you in the right direction. 

 

Posted

@Linken I forgot to mention that I have a .pk3 file with .ibi files for turning the feature on and off. I just don't know how to use them. Does the tutorial also cover that?

The .pk3 file has a scripts folder containing player_morelight_off.IBI, player_morelight_off.txt, player_morelight_on.IBI, player_morelight_on.txt. The .txt files hold the set command as done in the .cfg file and the .IBI is filled with some gibberish I can't decipher. I guess I will go read your tutorial to find out.

 

Thank you very much for responding so quickly

Posted
59 minutes ago, ssj4windu said:

@Linken I forgot to mention that I have a .pk3 file with .ibi files for turning the feature on and off. I just don't know how to use them. Does the tutorial also cover that?

The .pk3 file has a scripts folder containing player_morelight_off.IBI, player_morelight_off.txt, player_morelight_on.IBI, player_morelight_on.txt. The .txt files hold the set command as done in the .cfg file and the .IBI is filled with some gibberish I can't decipher. I guess I will go read your tutorial to find out.

 

Thank you very much for responding so quickly

When you're in game, in the console type "runscript player [path to your script]" which should make it work.

Posted
3 hours ago, Linken said:

When you're in game, in the console type "runscript player [path to your script]" which should make it work.

If it's packed inside a .pk3 how should I write the path? Or maybe I should unpack it and place it in the base folder?

Posted
22 hours ago, ssj4windu said:

If it's packed inside a .pk3 how should I write the path? Or maybe I should unpack it and place it in the base folder?

Usually the path starts with the scripts folder, so leaving it out, write the filepath to it.

For example, if it's just in your scripts folder, all you have to do is write the script name, which in this example we'll call "light"

If it's inside another folder, let's assume it's called "example", then you'd include the folder name followed by a slash.

So if you just have the script inside your "scripts" folder, then the command will be written like "runscript player light"

If it's inside the example folder, then it'll be written like "runscript player example/light"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...