Intent

From Screeps Wiki
Revision as of 23:13, 28 September 2020 by Donatzor (talk | contribs) (Created page with "Category:Intent 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 anot...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


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 you to preform that action. These checks go against your CPU, as your the one running them. Avoiding needless checks and duplicate/conflicting intents is a great way to keep your CPU usage low.