Skip to content

How to optimize Trigger for lag and space #63

Answered by armoha
armoha asked this question in Q&A
Discussion options

You must be logged in to vote

Why sample code are poorly written

Sample code occupies only 41 triggers at the expense of massive runtime lag.

  1. var i is EUDVariable, so address must be calculated during game.
    Calculating 0x628298 + 0x150 * (i-1) + 0x54 involves following trigger executions:
    • Subtract 1 in (i-1)
    • Multiply 0x150
    • Add 0x628298 and 0x64
    • EPD conversion takes subtraction and division: EPD = (ptr - 0x58A364) ÷ 4
    • These in-game arithmetics will take around 40 triggers and 80 actions.
  2. Copy-paste everywhere eagerly recalculates and never reuse known value.
    Simple refactoring quarters trigger executions.
    function setGroundCooldown() {
        const weaponCooldown = EUDArray(py_eval("[1] * 13 + [99] * 215"));
        for (var

Replies: 1 comment

Comment options

armoha
May 1, 2022
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by armoha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant