Site Logo


Danmakufu APM

This page details the Danmakufu APM in general, covering much of the content from the MotK thread (archive). For documentation or downloads, refer to GitHub

Why the APM?

Touhou Danmakufu ph3 is a language with many features that make it easy for new scripters to start coding and building games. Layers of abstraction and a clean (though occasionally limited) API make development easy, with the programmer not needing to understand the internals to build simple projects. However, when building full games, some of these abstractions and limitations become problematic issues requiring workarounds.

One major issue with Danmakufu is that it has terrible support for logging and debugging via error codes. There are only three debug functions - WriteLog(), RaiseError(), and assert().

To be blunt, Danmakufu's debug functionality is insufficient. For one, Danmakufu's console requires config options to be set up and requires that the log window be open during gameplay, lowering the FPS. It also captures EVERYTHING, resulting in your console messages being mixed with everything else the system spits out. In addition, WriteLog() ONLY accepts string inputs - if you want to have text and then a value, you need to use Danmakufu's ~ (concatenation operator) as well as the ToString() function to typecast what you want to output. If using RaiseError, it's similar, except the script stops execution, making it typically pointless unless you can't be bothered to open the log window.

For what it's worth, assert() does a good job... if you ever find a use for it, which is unlikely, as a failed assertion terminates the script, similarly to RaiseError(). Not something you'd want to release as part of a script to be played by people.

Beyond the debug functionality, it's also useful to have a sense of bullet counts and other statistics. You can set up text in a system script to track this live, of course, but the information can't be seen in a nice form. Hence, the APM.

What is the APM?

DNHAPM is a Danmakufu ph3 script that can be run in any stage/plural/single (recommended that you use a stage). It monitors playthroughs of your script, logs data, and on request, will spit out a report.

What do I mean by report? Well, take a look below!

FPS Monitoring

FPS Graph from the APM

Look at those lag spikes! At the S# notes (spell card declarations), the FPS tanks due to all of the fancy primitive effects in my spell card cutin animation. And the lag spike at 3m20s is probably the boss explosion - enough particle effects to knock any computer below 60 FPS!

But this FPS profiler also catches some less savory issues - gradual FPS drops near the ends of Nonspells 2 and 3. Maybe I should check those out and see if there are objects that aren't being deleted, hmm...

Graze Monitoring

Graze Graph from the APM

70 graze in the first nonspell?! Wow! The graze graph shows which spell cards the player grazed in. Interesting for level design, that's for sure!

Here you can see where heavy grazing occurred, or where grazing was particularly low.

Score Monitoring

Score Graph from the APM

Here you can see where your players are getting their score from (assuming score is enabled). This will probably correlate strongly with the graze graph, though with spikes for spell card captures, bullet clear bonuses, and other bonuses, like the stage clear bonus at the end.

Enemy Bullet Count Monitoring

Enemy Bullet Count Graph from the APM

Another interesting graph comes our way. With the enemy bullet count graph, you can see every time the player bombs (to an extent), as well as now the bullet count fluctuates over time.

In spells 2 and 3, the peaks are all around the same height - that's really good, since it means that all the bullets are deleting properly. But maybe having 1200 bullets on screen at once is a little problematic? Hmm... the graph still beats dredging through the lag-inducing log window.

Death & Bomb Monitoring

Death and Bomb Graph from the APM

This graph shows where the player died and bombed (image does not show bombs or prior runs). Taking a look at the graph gives a good sense of which parts are the deadliest. Some attacks are easier than others~

User-Defined Monitoring

No graph for this one, unfortunately, as this depends on what you need. Want to log points? Power? Your custom game-specific feature? If someone's cheating during an all-horizontal script? This is the tool for you :)

Usage

So what is this, really? It's a tool - for scripters - that takes data from the game and displays it in HTML + CSS + SVG for you to analyze. It's highly customizable, and more features are coming soon!

To use the project, head over to the GitHub page and go to Releases. The SparenDNHAPM_#.#.tar.gz file contains the project README as well as the .dnh file. The README on GitHub gives the full rundown of the project + configuration and usage and other details, but to summarize here:

  • Run the SparenDNHAPM.dnh script via @Loading in your target script
  • Ensure that you've configured everything the way you like
  • Ensure that you're outputting the report at a good time (DNHAPM requires at least 4 frames of buffer time between calling the event for report generation and closing the stage scene)
  • Add annotations in your spells/wherever you want to add notes
  • Run! voila!

There are some quirks that are detailed in the README, especially in regards to aggregating multiple runs, but this tool (still in development!) should be helpful to some scripters.

Potential use cases:

  • Embed into your release, distribute to beta testers, have them return the .csv files. Run the script on aggregate mode and look for trends in the graph (i.e. everyone is lagging here; something went wrong here; etc). Analyze, fix bugs, and profit.
  • Log runs to look for specific ways to optimize/find pain points in your script. For example, there is a bomb & death profiler that logs player deaths and bombs - should be interesting to see where players tend to die.
  • ... and many more.

LATEST VERSION: 1.0 [2018 JUL 23]

Have feedback, comments, bug reports, suggestions, etc? Please feel free to post here or create an issue on GitHub. This project is in continuous development and knowing what best helps other scripters make balanced, optimized games will help me tailor the project/add features that benefit the Danmakufu community.

--Sparen of Iria