Difference between revisions of "Intent"
Line 10: | Line 10: | ||
== Additional costs == |
== Additional costs == |
||
− | While most if not all intents do cost a flat 0.2 tax for changing the server side game-state, there are some additional costs to consider. Keep in mind that any time a user is executing a method, say <code>.harvest()</code> on a creep for example, the game must first check to see if its possible for |
+ | While most if not all intents do cost a flat 0.2 tax for changing the server side game-state, there are some additional costs to consider. Keep in mind that any time a user is executing a method, say <code>.harvest()</code> on a creep for example, the game must first check to see if its possible for a user can preform that action. These checks go against the user's CPU, as the user the one running them. Avoiding needless checks and duplicate/conflicting intents is a great way to keep CPU usage low. |
− | |||
== Bypassing checks / Issuing direct intents == |
== Bypassing checks / Issuing direct intents == |
Revision as of 13:27, 29 September 2020
An Intent is action a user is taking in game that results in a change to the game's database, this can range from a creep moving from one position to another using .move()
to executing a .deal()
in the market, to many, many other things. For an intent to be created, the method you are using must first pass all checks on the game's side and return a code of OK
. Actions/methods used that do not return OK, do not create intents. At that point, the intent will go into the queue to be executed for the user. The game charges a tax of 0.2 CPU for any intent that has an OK
returned to the user, regardless of if the intent is valid after the OK return.
Mainly, this means if you stack methods that all return OK, but conflict with each other or have a redundant effect, you will still be charged the 0.2 CPU for each intent regardless of the result. EX: A creep attempts to move into a wall terrain position, a tower attempts to repair a road that a creep is also repairing to full that tick. Both of these examples should (at time of writing) get you an OK return code, but will fail when the game attempts to execute your intent.
Not all methods in the game's API create intents or cost the 0.2 CPU to execute, you can see which do and do not by checking the top-right of the method's API page 'cost estimation'. If it has an "A", hovering over it with your mouse will reveal a tool-tip that explains there is a cost associated when OK is returned.
Additional costs
While most if not all intents do cost a flat 0.2 tax for changing the server side game-state, there are some additional costs to consider. Keep in mind that any time a user is executing a method, say .harvest()
on a creep for example, the game must first check to see if its possible for a user can preform that action. These checks go against the user's CPU, as the user the one running them. Avoiding needless checks and duplicate/conflicting intents is a great way to keep CPU usage low.
Bypassing checks / Issuing direct intents
The developers have been clear in stating that users should not bypass checks / issue direct intents (therby bypassing checks). Do not do it.