Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Tally/adding points in X amount of time [MMF2]


Asuma

Recommended Posts

So, basically, I want to add a certain amount let's say points, in like 2 seconds, no matter how big the value being added it. So, I have a base point of 1000. I win 20000 points. That 20000 additional points would be tallied to my current points within like 2 seconds. When 2 seconds is up, I would have a total of 21000. Then later I could get another 40000, which would tally an additional 40k to my current score which would make it 41000 when it's down tallying up the score.

Edited by Asuma
Link to comment
Share on other sites

Hm... I've thought of this before...

 

I would imagine that there 2 extra values... Points to add, and what the score will be when they are done adding.

 

So

 

Enemy is killed. Add 2,000 to points to add, set finished score to score plus points to add only 1 time. (this is so if you kill an enemy while points are still adding, the game will continue to add more points)

Points to add is greater than 0, every 15th of a second, (or come up with a formula to make it 2 seconds every time) add 1 to score, and subtract from points to add 1.

Score = finished score & points to add = 0, set finished score to 0 again.

 

Something like that would probably work. If you would like me to be more detailed and come up with some pseudo code, don't be afraid to ask.

Link to comment
Share on other sites

You got it: 

 

I'm using worlds type stuff for example, just note most of the below is 100% pseudo except for the motobug.

 

Alterable Values:

 

Score - Score, Duh

 

PointsToAdd - Amount of points being added to the score.

 

AddingFinished - The number of which the score will be when adding is completed.

 

PointAmount - How much points an enemy gives.

 

 

Only one action when even loops

Destroyed of ( "Badnik_MotoBug" ) = 1

     Set PointsToAdd of ( "Master_ScoreManagement" ) to PointsToAdd of ( "Master_ScoreManagement" )+PointAmount( "Badnik_MotoBug" )*

     Set AddingFinished ( "Master_ScoreManagement" ) to Score( "Master_ScoreManagement" )+PointAmount( "Badnik_MotoBug" )

 

Every 00"-15

PointsToAdd( "Master_ScoreManagement" )>0

     Add 1 to Score( "Master_ScoreManagement" )

     Sub 1 from PointsToAdd( "Master_ScoreManagement" )

 

Only one action when even loops

Score( "Master_ScoreManagement" ) = AddingFinished( "Master_ScoreManagement" )

PointsToAdd( "Master_ScoreManagement" ) = 0

     Set AddingFinished( "Master_ScoreManagement" ) to 0

 

*(I suppose you could just make this [Add PointAmount( "Badnik_MotoBug" ) to PointsToAdd( "Master_ScoreManagement" )], but whatever floats your boat)

Link to comment
Share on other sites

Awesome, this works, just need to find a way to do with within a timelimit. I found away to it via fastlopp, but too high of a number can cause crashes. Basically what I did was, when I set an amount to be added, I ran a loop "add" to run the amount of times of the points added divided by a number.

sheetofeent.png

Edited by Asuma
  • Like 1
Link to comment
Share on other sites

You shouldnt need loops for this.  Just have the total score recorded immediately when it's gained. The counter that displays the score should add the difference in 2 seconds (120 frames) by adding the total value in percentages.

 

So if your score was 100, and you gained 40,000 points, you add 40,000/120 to your counter every frame. In 120 frames, it will have added 40,000.

 

TotalScore = 40,000  (This is your total score value)

 

DisplayedScore = 100 (Whatever the current value of the displayed counter is)

 

 

 

 

Always (Every Tick) >> Add TotalScore /120  (or * 0.0083ish) to DisplayedScore

 

if Displayed Score > TotalScore

Set Displayed Score to TotalScore.

 

 

 

Using loops for something like this is a massive waste of resources.

Edited by Serephim
  • Like 1
Link to comment
Share on other sites

The second condition is basically undoing what you do in the first condition.

Your first condition correctly adds the 120th part of the total every frame, but your second condition sets DisplayedScore (the value you're adding to) to TotalScore right away, since we assume that DisplayedScore is less than TotalScore. Open the debugger and see how the value behaves. At least this is what I'm seeing here.

Link to comment
Share on other sites

I screwed that up too, wow sorry.

 

The second condition should be, if displayed score is GREATER than Total score, then set it to Total Score. Just flip the operator. 

 

Also, you can make the counter increase faster or slower by changing the amount you divide the TotalScore by. This would be useful for an act end score tally or something.

 

Basically, convert seconds to your target FPS.  At 60FPS,  /60 completes the tally in one second, /30 is half a second, ect.

Edited by Serephim
Link to comment
Share on other sites

Ah, Okay. Now I remember what TargetScore was supposed to be for.  Nope still didn't need it nvm. Okay so this method will always reach any size target value within a max of 120 frames, but that's assuming you're starting from 0. Increasing the score will only add more ticks per second to maintain it. If you want it to take 2 seconds to update the total anytime the score increases, then you're going to need to record both the total score and the last displayed score, subtract that from the total, and run the logic on that.

 

So, anytime you add anything to Total Score:

 

Add > [new points] to TotalScore  // This updates the total score as usual

Set > StartingScore to DisplayedScore  // This saves the last position of the displayed value

 

 

Now for the counter events:

 

Always:

Add > (TotalScore-StartingScore)/120 to DisplayedScore

 

 

So (from zero) if you're at 90,000 / 100,000 score being displayed, and you gain +10 points, instead of:

 

100,010/120 = 833.41 per tick, which would finish in 12 ticks

 

you get

 

10,010/120 =  83.41 per tick, which would finish in another 120. **Edited to fix the logic.

Edited by Serephim
Link to comment
Share on other sites

Hmmmm, someone ask for rolling counters?

 

Two events... at least when you know it will always go up like score.

 

rolling_counters_v1.mfa

 

EDIT:  MMF text boxes suck at reacting to clicks, so use the tab key.

 

 

 

Caveats:  In the above example, if you have a large score that gets accrued slowly immediately followed by a small score that gets accrued quickly, quick wins and the large score will be combined with the small score and added quickly.  Example:

 

player kills boss monster and gets 50000 points that are supposed to be accrued over 10 seconds, ~83 points are added per frame for the next 5 seconds.

 

With 5 seconds remaining and 25000 points to go, the player kills a monster that is worth 200 points and gets added over 30 frames

 

30 frames later, the player's score will have both the remaining 25000 points from the boss and the 200 points from the little monster.

 

If you want something more elaborate... say something that can track multiple accruals on their own timer, then you'll probably need to use an array set up as a queue.  I don't imagine too many people need that sort of thing though.

 

I might do the example anyway just to demonstrate my baller-status.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...