Jump to content
The Dark Mod Forums

2 Bugs and a patch for 0003304: "add scripting events to get mission statistics"


Zbyl

Recommended Posts

Hi,

 

I've made a patch for 0003304: "add scripting events to get mission statistics".

http://bugs.thedarkm...iew.php?id=3304

 

The kind of events needed is something that maybe needs discussing, so consider this patch a proposal.

Some things to consider:

  • I've added those events to the "sys" entity. But maybe they should be on player or other entity?
  • I've added events for all statistics used in UpdateStatisticsGUI(). But maybe there should be more flexible events, like getMissionStatistic(COMP_ALERT, BY_TEAM, 1, EAgitatedSearching)?
  • Are the names of the events ok?
  • getStatGamePlayTime() returns time in seconds, while getStatTotalTimePlayerSeen() in milliseconds. Normalize?

Here is the list of script events I've added (getDifficultyLevel() should be there already):

 

 

 

// Scripting events to get mission statistics, #3304

scriptEvent float getDifficultyLevel();

scriptEvent string getDifficultyName(float difficultyLevel);

scriptEvent float getStatGamePlayTime();

scriptEvent float getStatDamageDealt();

scriptEvent float getStatDamageReceived();

scriptEvent float getStatHealthReceived();

scriptEvent float getStatPocketsPicked();

scriptEvent float getStatFoundLoot();

scriptEvent float getStatMissionLoot();

scriptEvent float getStatTotalTimePlayerSeen();

scriptEvent float getStatNumberTimesPlayerSeen();

scriptEvent float getStatNumberTimesAISuspicious();

scriptEvent float getStatNumberTimesAISearched();

scriptEvent float getStatSightingScore();

scriptEvent float getStatStealthScore();

scriptEvent float getStatKilledByPlayer();

scriptEvent float getStatKnockedOutByPlayer();

scriptEvent float getStatBodiesFound();

 

(Those lines are not included in the patch as I don't have access to current data files.)

 

 

Changes:

  • Fixed bug in checking bounds for AIAlerts in CMissionData::GetStat*() methods.
  • Sorted methods in MissionData.h to group stat functions together.
  • Added accessor functions to all values that are used in UpdateStatisticsGUI() - so that this function and script events use consistent interface.
  • Added mission stats events to "sys" entity.
  • Added event descriptions to tdm_events.script (not included in patch).
  • Changed MAX_AICOMP in MissionStatistics.h to be equal to COMP_COUNT.
  • Added include "../AI/Memory.h" in MissionStatistics.h to use EAlertState enum in MAX_ALERTLEVELS and CMissionData.
  • Changed hard coded values to EAlertState enum values in MissionData.cpp.

While testing those events I've found some issues:

 

 

1. A bug that causes pickpocketting to be counted twice. InventoryCallback() is called twice:

Code in CInventory::PutItem(idEntity * ent, idEntity * owner)

PutItem(item, category); // <-- InventoryCallback() is already called here!

// We added a new inventory item
gameLocal.m_MissionData->InventoryCallback(...); // <-- second call - double COMP_PICKPOCKET counting!

 

2. A bug that causes enemies killed by player to not be counted as player's kills.

 

In idPhysics_AF::Rest() there's a line:

// grayman #3075 - set m_MovedByActor to NULL here
self->m_MovedByActor = NULL;

 

This causes bodies killed by the player to not count as player's kills as soon as their bodies come to rest!

I understand this code is needed for props, but should be disabled for dead bodies.

 

I couldn't find those in the bugtracker. If they are not known I can create issues for them.

MissionStats.patch.txt

  • Like 2
Link to comment
Share on other sites

Wow, loads of stuff :)

 

To anyone that might merge : Can you just hold off, a lot of this stuff is hopefully changing soon, I really don't feel like having to merge this one twice. I'd really just like the tree frozen atm, but I can't :)

  • Shouldn't really be on sys, but... not too sure where else it'd be good.
  • Don't really need more flexibility in events and stuff, TDM already has overkill flexibility in many systems. Already have loads of stats here, which arn't really a core feature.

If you'd like to talk about stuff, please feel free to join irc #thedarkmod on freenode. I'm usually around. Also might be good to have you there as I'm starting to move back to SDL-less system stuff, having more platforms that can be tested would be nice :)

Link to comment
Share on other sites

1. A bug that causes pickpocketting to be counted twice. InventoryCallback() is called twice:

2. A bug that causes enemies killed by player to not be counted as player's kills.

 

I couldn't find those in the bugtracker. If they are not known I can create issues for them.

 

Please create bugtracker issues for these 2. I'd have to look more closely at the second one, because I made that change for a reason, and I don't want to undo that until I remember what the reason was, and understand how to accomplish what I wanted to do, plus eliminate the miscount.

 

For the first one, have you tested that one pickpocket turns into two on the mission stats screen? I don't recall anyone ever complaining about that.

Link to comment
Share on other sites

Shouldn't really be on sys, but... not too sure where else it'd be good.

As all the objective methods are on the player, these here may fit there, too. It makes sense as these methods provide information about what the player has done.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Some comments:

 

* you need a bug tracker account and then assign bugs to yourself, that way people can see what you are working on (Not a big deal, but I also worked on this bug in the meantime, but forgot to assign it to myself because I got busy in RL and also am waiting forever for Serpentine to merge his changes. This can get confusing).

 

* you also should have access to the SVN - if you haven't?

 

* scripting events on the script side are no longer declared, this file is only for documentation purposes and can be reghenerated from the console (ideally every time a scripting event is added, but lately I only did it once every few weeks because this file is only visible to mappers after a release, anyway)

 

* put them on the player object - remember, in possible multiplayer, there can be more than one player, so every player should have his own statistics.

 

* As for all these events, I was pondering instead of adding only one event that you can call like:

 

float damage = $player1.getMissionStats( "damageDealt" );  // case does not matter

 

Because otherwise we end up with a dozend new functions instead of one - and I don't think the speed difference (parsing the string) will make any difference for functions that are called seldom enough.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

Yep, great work dude.

 

I would second what Tels said. Keep it on the player and try the string-based function call. I use script events quite often in my maps and would appreciate it :smile:

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I'va added two issues to the bugtracker:

0003313: Picked pockets are counted twice (http://bugs.thedarkm...iew.php?id=3313)

0003314: Found bodies of enemies killed by player do not count to 'Bodies found' (http://bugs.thedarkm...iew.php?id=3314)

I've clarified the issue in the second one, since the original description was not very clear.

 

* you need a bug tracker account and then assign bugs to yourself, that way people can see what you are working on (Not a big deal, but I also worked on this bug in the meantime, but forgot to assign it to myself because I got busy in RL and also am waiting forever for Serpentine to merge his changes. This can get confusing).

 

I have only reporter status, so I can't edit or assign bugs to myself. If you have a patch ready then ignore mine. Otherwise I'll modify mine to include suggestions in this thread.

 

* you also should have access to the SVN - if you haven't?

 

I have access to the public SVN - read only.

Also newest data files are not public.

Link to comment
Share on other sites

Revised patch that defines just one sript function:

/**
* Returns current mission statistic.
*
* @statisticName: Can be one of (case insensitive):
*  gamePlayTime: gameplay time in seconds
*  damageDealt: damage dealt to enemies
*  damageReceived: damage recieved by player
*  healthReceived: health recieved by player
*  pocketsPicked: pockets picked by player
*  foundLoot: loot found by player
*  missionLoot: total loot available in mission
*  totalTimePlayerSeen: total time the player was seen by enemies in milliseconds
*  numberTimesPlayerSeen: number of times player was seen by enemies
*  numberTimesAISuspicious: number of times AI was 'observant' or 'suspicious'
*  numberTimesAISearched: number of times AI was 'investigating' or 'searching'
*  sightingScore: sighting score (number of times player was seen * weight)
*  stealthScore: stealth score (sighting score + alerts * weights)
*  killedByPlayer: number of enemies killed by player
*  knockedOutByPlayer: number of enemies knocked out by player
*  bodiesFound: number of bodies found by enemies
*/
scriptEvent float  getMissionStatistic(string statisticName);

MissionStats2.patch.txt

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...