rpgsync 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rpgsync/dsl.py ADDED
@@ -0,0 +1,2616 @@
1
+ """The event script language of rpgsync: typed and documented vocabulary.
2
+
3
+ Every script starts with ``from rpgsync.dsl import *``. rpgsync *parses*
4
+ scripts and never runs them, so nothing here does anything at runtime: the
5
+ classes and signatures exist so that editors autocomplete, show these docs
6
+ on hover, and type checkers (ty, pyright) flag wrong values while you type.
7
+
8
+ Example::
9
+
10
+ @event(9, "Guard", x=10, y=5)
11
+ class Guard(Event):
12
+ sprite = ("Actor1", 3)
13
+ layer = "same"
14
+
15
+ def page_1(self):
16
+ \"\"\"Asks for the toll (stored in the game as the page's first comment)\"\"\"
17
+ text("Halt!")
18
+ if variables[1] >= variables[2]:
19
+ party.gold -= 100
20
+ match show_choices("Pay", "Leave"):
21
+ case "Pay":
22
+ switches[4] = True
23
+ case "Leave":
24
+ this.move(move_away_from_player, frequency=6)
25
+ return
26
+
27
+ @page(when=switches[4])
28
+ def page_2(self):
29
+ text("Welcome back.")
30
+
31
+ Conventions:
32
+
33
+ * Ranges use Python slices: ``variables[1:11]`` is variables 1 to 10.
34
+ * Most numbers can also be given as ``variables[id]`` (the value is read
35
+ when the command runs).
36
+ * ``extra=(...)`` keeps raw parameters added by newer editor versions or
37
+ patches; ``some_field=None`` marks a parameter that older editors did not
38
+ write. Both are generated by rpgsync to keep data byte-identical; you
39
+ rarely need them yourself.
40
+ * Python ``#`` comments on their own line are stored as RPG Maker comments.
41
+ """
42
+
43
+ from __future__ import annotations
44
+
45
+ from collections.abc import Callable
46
+ from contextlib import AbstractContextManager, nullcontext
47
+ from typing import TYPE_CHECKING, Literal, Never, Protocol, TypeVar, overload
48
+
49
+ _F = TypeVar("_F", bound=Callable[..., object])
50
+ _E = TypeVar("_E", bound="Event")
51
+
52
+ # ==========================================================================
53
+ # Accepted values
54
+ # ==========================================================================
55
+
56
+ Direction = Literal["up", "right", "down", "left"]
57
+ """A facing direction."""
58
+ TeleportDirection = Literal["retain", "up", "right", "down", "left"]
59
+ """Facing after a teleport / move: ``"retain"`` keeps the current one."""
60
+ Trigger = Literal["action", "touch", "collision", "autorun", "parallel"]
61
+ """How an event page starts:
62
+
63
+ * ``"action"``: the player presses the action key next to it (or on it).
64
+ * ``"touch"``: the player walks into it.
65
+ * ``"collision"``: the player walks into it, or it walks into the player.
66
+ * ``"autorun"``: starts by itself and blocks the player until it ends.
67
+ * ``"parallel"``: runs repeatedly in the background while the player moves.
68
+ """
69
+ Layer = Literal["below", "same", "above"]
70
+ """Drawing/collision layer of an event: below the hero (walkable), same as
71
+ the hero (blocks, can be talked to) or above the hero."""
72
+ MoveType = Literal["stationary", "random", "vertical", "horizontal", "toward_player", "away_from_player", "custom"]
73
+ """Automatic movement of an event page (``"custom"`` uses ``route=``)."""
74
+ Pattern = Literal["left", "middle", "right", "middle2"]
75
+ """Animation frame of the sprite shown when the event stands still."""
76
+ AnimationType = Literal[
77
+ "non_continuous",
78
+ "continuous",
79
+ "fixed_non_continuous",
80
+ "fixed_continuous",
81
+ "fixed_graphic",
82
+ "spin",
83
+ "step_frame_fix",
84
+ ]
85
+ """How the sprite animates: walking only when moving (non_continuous),
86
+ always (continuous), with a fixed direction, frozen (fixed_graphic) or
87
+ spinning."""
88
+ Speed = Literal[1, 2, 3, 4, 5, 6]
89
+ """Movement speed: 1 = 1/8, 2 = 1/4, 3 = 1/2, 4 = normal, 5 = x2, 6 = x4."""
90
+ Frequency = Literal[1, 2, 3, 4, 5, 6, 7, 8]
91
+ """How often an event acts: 1 = rarely ... 8 = continuously. It affects
92
+ moving, turning and waiting, not graphic changes."""
93
+ SpriteIndex = Literal[0, 1, 2, 3, 4, 5, 6, 7] | int # int: a value the editor cannot set
94
+ """Which of the 8 characters of a CharSet image (288x256), counted left to
95
+ right, top to bottom, from 0 at the top left::
96
+
97
+ +---+---+---+---+
98
+ | 0 | 1 | 2 | 3 |
99
+ +---+---+---+---+
100
+ | 4 | 5 | 6 | 7 |
101
+ +---+---+---+---+
102
+
103
+ Each character block holds 3 walking frames across and 4 directions down
104
+ (up, right, down, left); the page's ``direction`` and ``pattern`` pick the
105
+ pose inside it."""
106
+ FaceIndex = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
107
+ """Which of the 16 faces (48x48) of a FaceSet image, counted left to right,
108
+ top to bottom: 0-3 on the first row ... 12-15 on the last."""
109
+ CommonEventTrigger = Literal["call", "autorun", "parallel"]
110
+ """When a common event runs: only when called, automatically (blocking), or
111
+ in parallel; autorun/parallel common events need their condition switch ON."""
112
+ MessagePosition = Literal["top", "middle", "bottom"]
113
+ Vehicle = Literal["boat", "ship", "airship"]
114
+ CancelOption = Literal[1, 2, 3, 4]
115
+ Digits = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9] | int # 8-9: Maniac Patch; int: a value the editor cannot set
116
+ Transition = (
117
+ Literal[
118
+ "default",
119
+ "fade",
120
+ "random_blocks",
121
+ "random_blocks_down",
122
+ "random_blocks_up",
123
+ "blinds",
124
+ "vertical_stripes",
125
+ "horizontal_stripes",
126
+ "border_to_center",
127
+ "center_to_border",
128
+ "scroll_up",
129
+ "scroll_down",
130
+ "scroll_left",
131
+ "scroll_right",
132
+ "vertical_split",
133
+ "horizontal_split",
134
+ "cross_split",
135
+ "zoom",
136
+ "mosaic",
137
+ "ripple",
138
+ "instant",
139
+ "none",
140
+ ]
141
+ | int
142
+ ) # int: a value the editor cannot set
143
+ """Screen transition; ``"default"`` uses the one set in the database
144
+ (System tab) or with set_transition()."""
145
+ TransitionKind = (
146
+ Literal[
147
+ "teleport_erase",
148
+ "teleport_show",
149
+ "battle_start_erase",
150
+ "battle_start_show",
151
+ "battle_end_erase",
152
+ "battle_end_show",
153
+ ]
154
+ | int
155
+ ) # int: a value the editor cannot set
156
+ WeatherKind = Literal["none", "rain", "snow", "fog", "sandstorm"]
157
+ Strength = Literal["weak", "medium", "strong"]
158
+ FlashMode = Literal["once", "begin", "end"]
159
+ """``"once"`` flashes/shakes once; ``"begin"`` repeats until ``"end"`` (2003)."""
160
+ PictureEffect = Literal["none", "rotation", "wave"] | int # int: a value the editor cannot set
161
+ Stat = Literal["max_hp", "max_sp", "attack", "defense", "spirit", "agility"]
162
+ EquipSlot = Literal["weapon", "shield", "armor", "helmet", "accessory", "all"]
163
+ BgmContext = (
164
+ Literal["battle", "victory", "inn", "boat", "ship", "airship", "game_over"] | int
165
+ ) # int: a value the editor cannot set
166
+ SeContext = (
167
+ Literal[
168
+ "cursor",
169
+ "decision",
170
+ "cancel",
171
+ "buzzer",
172
+ "battle_start",
173
+ "escape",
174
+ "enemy_attack",
175
+ "enemy_damaged",
176
+ "ally_damaged",
177
+ "evade",
178
+ "enemy_dies",
179
+ "item",
180
+ ]
181
+ | int
182
+ ) # int: a value the editor cannot set
183
+ SkillMode = Literal["keep", "replace", "add"]
184
+ StatMode = Literal["keep", "halve", "level1", "current_level"]
185
+
186
+ # Command names accepted by cmd(...), from liblcf.
187
+ CommandName = Literal[
188
+ "BreakLoop",
189
+ "CallCommonEvent",
190
+ "CallEvent",
191
+ "ChangeActorFace",
192
+ "ChangeBattleBG",
193
+ "ChangeBattleCommands",
194
+ "ChangeClass",
195
+ "ChangeCondition",
196
+ "ChangeEncounterSteps",
197
+ "ChangeEquipment",
198
+ "ChangeEscapeAccess",
199
+ "ChangeEventLocation",
200
+ "ChangeExp",
201
+ "ChangeFaceGraphic",
202
+ "ChangeGold",
203
+ "ChangeHP",
204
+ "ChangeHeroName",
205
+ "ChangeHeroTitle",
206
+ "ChangeItems",
207
+ "ChangeLevel",
208
+ "ChangeMainMenuAccess",
209
+ "ChangeMapTileset",
210
+ "ChangeMonsterCondition",
211
+ "ChangeMonsterHP",
212
+ "ChangeMonsterMP",
213
+ "ChangePBG",
214
+ "ChangeParameters",
215
+ "ChangePartyMembers",
216
+ "ChangeSP",
217
+ "ChangeSaveAccess",
218
+ "ChangeScreenTransitions",
219
+ "ChangeSkills",
220
+ "ChangeSpriteAssociation",
221
+ "ChangeSystemBGM",
222
+ "ChangeSystemGraphics",
223
+ "ChangeSystemSFX",
224
+ "ChangeTeleportAccess",
225
+ "ChangeVehicleGraphic",
226
+ "Comment",
227
+ "Comment_2",
228
+ "ConditionalBranch",
229
+ "ConditionalBranch_B",
230
+ "ControlSwitches",
231
+ "ControlVars",
232
+ "DefeatHandler",
233
+ "END",
234
+ "ElseBranch",
235
+ "ElseBranch_B",
236
+ "EnableCombo",
237
+ "EndBattle",
238
+ "EndBranch",
239
+ "EndBranch_B",
240
+ "EndEventProcessing",
241
+ "EndInn",
242
+ "EndLoop",
243
+ "EndShop",
244
+ "EnemyEncounter",
245
+ "EnterExitVehicle",
246
+ "EnterHeroName",
247
+ "EraseEvent",
248
+ "ErasePicture",
249
+ "EraseScreen",
250
+ "EscapeHandler",
251
+ "EscapeTarget",
252
+ "ExitGame",
253
+ "FadeOutBGM",
254
+ "FlashScreen",
255
+ "FlashSprite",
256
+ "ForceFlee",
257
+ "FullHeal",
258
+ "GameOver",
259
+ "HaltAllMovement",
260
+ "InputNumber",
261
+ "JumpToLabel",
262
+ "KeyInputProc",
263
+ "Label",
264
+ "Loop",
265
+ "MemorizeBGM",
266
+ "MemorizeLocation",
267
+ "MessageOptions",
268
+ "MoveEvent",
269
+ "MovePicture",
270
+ "NoStay",
271
+ "NoTransaction",
272
+ "OpenLoadMenu",
273
+ "OpenMainMenu",
274
+ "OpenSaveMenu",
275
+ "OpenShop",
276
+ "OpenVideoOptions",
277
+ "PanScreen",
278
+ "PlayBGM",
279
+ "PlayMemorizedBGM",
280
+ "PlayMovie",
281
+ "PlaySound",
282
+ "PlayerVisibility",
283
+ "ProceedWithMovement",
284
+ "RecallToLocation",
285
+ "ReturntoTitleScreen",
286
+ "SetVehicleLocation",
287
+ "ShakeScreen",
288
+ "ShowBattleAnimation",
289
+ "ShowBattleAnimation_B",
290
+ "ShowChoice",
291
+ "ShowChoiceEnd",
292
+ "ShowChoiceOption",
293
+ "ShowHiddenMonster",
294
+ "ShowInn",
295
+ "ShowMessage",
296
+ "ShowMessage_2",
297
+ "ShowPicture",
298
+ "ShowScreen",
299
+ "SimulatedAttack",
300
+ "Stay",
301
+ "StoreEventID",
302
+ "StoreTerrainID",
303
+ "TeleportTargets",
304
+ "Teleport",
305
+ "TerminateBattle",
306
+ "TileSubstitution",
307
+ "TimerOperation",
308
+ "ToggleAtbMode",
309
+ "ToggleFullscreen",
310
+ "TradeEventLocations",
311
+ "Transaction",
312
+ "VictoryHandler",
313
+ "Wait",
314
+ "WeatherEffects",
315
+ ]
316
+
317
+ Extra = tuple[int, ...]
318
+ """Raw trailing parameters kept for lossless round trips (newer editors, patches)."""
319
+
320
+
321
+ # ==========================================================================
322
+ # Values and conditions
323
+ # ==========================================================================
324
+
325
+
326
+ class Condition:
327
+ """Something an ``if`` or ``@page(when=...)`` can test."""
328
+
329
+ def __bool__(self) -> bool: ...
330
+
331
+
332
+ class Value:
333
+ """A number read from the game when the command runs (a variable, a
334
+ stat, the gold...). Compare it to get a condition:
335
+ ``variables[1] >= 10``, ``variables[1] == variables[2]``."""
336
+
337
+ def __eq__(self, other: object) -> Condition: ... # type: ignore[override]
338
+ def __ne__(self, other: object) -> Condition: ... # type: ignore[override]
339
+ def __lt__(self, other: int | Value) -> Condition: ...
340
+ def __le__(self, other: int | Value) -> Condition: ...
341
+ def __gt__(self, other: int | Value) -> Condition: ...
342
+ def __ge__(self, other: int | Value) -> Condition: ...
343
+ def __neg__(self) -> Value: ...
344
+ def __pos__(self) -> Value: ...
345
+
346
+
347
+ Number = int | Value
348
+ """A number, or a value read from the game such as ``variables[3]``."""
349
+
350
+ if TYPE_CHECKING:
351
+ # written by rpgsync into each game's Scripts/database: Variable when the game
352
+ # runs the DynParams plugin, else Never
353
+ from database.game_types import Dynamic # type: ignore
354
+ else:
355
+ Dynamic = Never
356
+
357
+ Fixed = int | Dynamic
358
+ """A number that RPG Maker keeps as such in the command. In a game that runs the
359
+ DynParams plugin (DynPlugins/DynParams.dll), also a variable such as
360
+ ``variables.id``: its value is used when the command runs."""
361
+
362
+
363
+ class Counter(Value):
364
+ """A value changed with ``+=`` / ``-=`` (gold, item counts)."""
365
+
366
+ def __iadd__(self, amount: Number) -> Counter: ...
367
+ def __isub__(self, amount: Number) -> Counter: ...
368
+
369
+
370
+ class Variable(Value):
371
+ """One game variable, ``variables[id]``.
372
+
373
+ Assign with ``=``, change with ``+= -= *= //= %=`` (``%`` is the
374
+ remainder: 1953 % 100 = 53). Values range from -9999999 to 9999999 in
375
+ RPG Maker 2003 (-999999 to 999999 in 2000)."""
376
+
377
+ def __iadd__(self, value: Number) -> Variable: ...
378
+ def __isub__(self, value: Number) -> Variable: ...
379
+ def __imul__(self, value: Number) -> Variable: ...
380
+ def __ifloordiv__(self, value: Number) -> Variable: ...
381
+ def __imod__(self, value: Number) -> Variable: ...
382
+
383
+
384
+ class VariableRange:
385
+ """``variables[first:last+1]``: the same operation on every variable of the range."""
386
+
387
+ def __iadd__(self, value: Number) -> VariableRange: ...
388
+ def __isub__(self, value: Number) -> VariableRange: ...
389
+ def __imul__(self, value: Number) -> VariableRange: ...
390
+ def __ifloordiv__(self, value: Number) -> VariableRange: ...
391
+ def __imod__(self, value: Number) -> VariableRange: ...
392
+
393
+
394
+ class Variables:
395
+ """All game variables: ``variables[5]``, ``variables[1:11]`` (1 to 10),
396
+ ``variables[variables[3]]`` (the variable whose id is stored in variable 3).
397
+
398
+ Pointers (arrays, tables)::
399
+
400
+ variables.ptr = variables.slot
401
+ variables.ptr += 2001 # the array starts at 2001
402
+ variables.hp = variables[variables.ptr] # read
403
+ variables[variables.ptr] += 10 # write
404
+
405
+ A branch can't test ``variables[variables.ptr]`` directly: copy it into a
406
+ variable first. There is no maths inside ``[]``: move the pointer instead."""
407
+
408
+ @overload
409
+ def __getitem__(self, key: int | Variable) -> Variable: ...
410
+ @overload
411
+ def __getitem__(self, key: slice) -> VariableRange: ...
412
+ def __getitem__(self, key): ...
413
+ def __setitem__(self, key: int | Variable | slice, value: Number | VariableRange | Variable) -> None: ...
414
+
415
+
416
+ class Switch(Condition):
417
+ """One game switch, ``switches[id]`` (ON/OFF). Set it with ``= True`` /
418
+ ``= False``, test it with ``if switches[id]:`` or ``if not switches[id]:``."""
419
+
420
+ def toggle(self) -> None:
421
+ """Flip the switch: ON becomes OFF and OFF becomes ON."""
422
+
423
+
424
+ class SwitchRange:
425
+ """``switches[first:last+1]``: several switches at once."""
426
+
427
+ def toggle(self) -> None:
428
+ """Flip every switch of the range."""
429
+
430
+
431
+ class Switches:
432
+ """All game switches: ``switches[5]``, ``switches[1:11]`` (1 to 10),
433
+ ``switches[variables[3]]`` (the switch whose id is in variable 3: it can
434
+ be set, but RPG Maker can't test it)."""
435
+
436
+ @overload
437
+ def __getitem__(self, key: int | Variable) -> Switch: ...
438
+ @overload
439
+ def __getitem__(self, key: slice) -> SwitchRange: ...
440
+ def __getitem__(self, key): ...
441
+ def __setitem__(self, key: int | Variable | slice, value: bool) -> None: ...
442
+
443
+
444
+ class Item:
445
+ """``items[id]``: an item of the database. ``items[3].count += 2`` gives
446
+ two, ``if items[3] in party:`` tests possession. The inventory is sorted
447
+ by item id."""
448
+
449
+ count: Counter
450
+ """How many the party holds."""
451
+ equipped: Value
452
+ """How many are currently equipped by party members."""
453
+
454
+
455
+ class Items:
456
+ def __getitem__(self, key: int | Variable) -> Item: ...
457
+
458
+
459
+ class Actor:
460
+ """``actors[id]``: a hero of the database (in the party or not)."""
461
+
462
+ name: str
463
+ """The hero's name; assign to rename (``actors[1].name = "Alex"``).
464
+ Message codes work in it, but not \\v[] (variable display)."""
465
+ title: str
466
+ """The hero's title (grade); assign to change it."""
467
+ level: Value
468
+ exp: Value
469
+ hp: Value
470
+ sp: Value
471
+ max_hp: Value
472
+ max_sp: Value
473
+ attack: Value
474
+ defense: Value
475
+ spirit: Value
476
+ agility: Value
477
+ weapon: Value
478
+ """Id of the equipped weapon (0 = none)."""
479
+ shield: Value
480
+ armor: Value
481
+ helmet: Value
482
+ accessory: Value
483
+ can_act: Condition
484
+ """In ``battle_condition(...)``: the hero can act this turn."""
485
+
486
+ def knows(self, skill: Fixed) -> Condition:
487
+ """Condition: the hero has learned this skill."""
488
+
489
+ def has_equipped(self, item: Fixed) -> Condition:
490
+ """Condition: the hero has this item equipped."""
491
+
492
+ def has_state(self, state: Fixed) -> Condition:
493
+ """Condition: the hero has this state (poison, sleep...)."""
494
+
495
+ def uses_command(self, command: Fixed) -> Condition:
496
+ """In ``battle_condition(...)`` and troop page conditions: the hero uses this
497
+ battle command (2003)."""
498
+
499
+ def hp_percent(self, min: int = 0, max: int = 100) -> Condition:
500
+ """Troop page condition: the hero's HP is between min% and max% of its max HP."""
501
+
502
+ def turn(self, start: int, every: int = 0) -> Condition:
503
+ """Troop page condition (2003): the hero's own turn count is ``start``, then
504
+ every ``every`` turns (``every=0``: that turn only)."""
505
+
506
+ def set_sprite(
507
+ self, charset: str, index: Fixed | None = None, transparent: bool | None = None, *, extra: Extra = ()
508
+ ) -> None:
509
+ """Change the hero's walking sprite.
510
+
511
+ Args:
512
+ charset: CharSet image name.
513
+ index: character in the CharSet image (0-7).
514
+ transparent: draw the hero semi-transparent.
515
+ """
516
+
517
+ def set_face(self, faceset: str, index: Fixed | None = None, *, extra: Extra = ()) -> None:
518
+ """Change the hero's face (used by messages and menus).
519
+
520
+ Args:
521
+ faceset: FaceSet image name.
522
+ index: face in the FaceSet image (0-15).
523
+ """
524
+
525
+
526
+ class Actors:
527
+ def __getitem__(self, key: int | Variable) -> Actor: ...
528
+
529
+
530
+ class MoveStep:
531
+ """One step of a move route (move_up, face_player, switch_on(3), ...).
532
+ ``move_up * 3`` repeats a step."""
533
+
534
+ def __mul__(self, count: int) -> MoveStep: ...
535
+
536
+
537
+ # ==========================================================================
538
+ # Move route steps
539
+ # ==========================================================================
540
+
541
+ move_up = MoveStep()
542
+ """Move one tile up."""
543
+ move_right = MoveStep()
544
+ """Move one tile right."""
545
+ move_down = MoveStep()
546
+ """Move one tile down."""
547
+ move_left = MoveStep()
548
+ """Move one tile left."""
549
+ move_up_right = MoveStep()
550
+ """Move one tile diagonally up-right."""
551
+ move_down_right = MoveStep()
552
+ """Move one tile diagonally down-right."""
553
+ move_down_left = MoveStep()
554
+ """Move one tile diagonally down-left."""
555
+ move_up_left = MoveStep()
556
+ """Move one tile diagonally up-left."""
557
+ move_random = MoveStep()
558
+ """Move one tile in a random direction."""
559
+ move_toward_player = MoveStep()
560
+ """Move one tile toward the player."""
561
+ move_away_from_player = MoveStep()
562
+ """Move one tile away from the player."""
563
+ move_forward = MoveStep()
564
+ """Move one tile in the facing direction."""
565
+ face_up = MoveStep()
566
+ """Turn to face up."""
567
+ face_right = MoveStep()
568
+ """Turn to face right."""
569
+ face_down = MoveStep()
570
+ """Turn to face down."""
571
+ face_left = MoveStep()
572
+ """Turn to face left."""
573
+ turn_right = MoveStep()
574
+ """Turn 90 degrees clockwise."""
575
+ turn_left = MoveStep()
576
+ """Turn 90 degrees counterclockwise."""
577
+ turn_around = MoveStep()
578
+ """Turn 180 degrees."""
579
+ turn_random = MoveStep()
580
+ """Turn 90 degrees left or right at random."""
581
+ face_random = MoveStep()
582
+ """Face a random direction."""
583
+ face_player = MoveStep()
584
+ """Face the player."""
585
+ face_away_from_player = MoveStep()
586
+ """Turn the back to the player."""
587
+ pause = MoveStep()
588
+ """Wait one movement step."""
589
+ jump_start = MoveStep()
590
+ """Start a jump: the following movement steps set where it lands."""
591
+ jump_end = MoveStep()
592
+ """End a jump started with jump_start: land where the steps in between lead."""
593
+ lock_facing = MoveStep()
594
+ """Keep the current facing direction while moving."""
595
+ unlock_facing = MoveStep()
596
+ """Face the direction of movement again."""
597
+ speed_up = MoveStep()
598
+ """Move one speed faster (speeds go from 1 to 6)."""
599
+ speed_down = MoveStep()
600
+ """Move one speed slower."""
601
+ frequency_up = MoveStep()
602
+ """Act more often (frequency goes from 1 to 8)."""
603
+ frequency_down = MoveStep()
604
+ """Act less often."""
605
+ phasing_on = MoveStep()
606
+ """Walk through everything."""
607
+ phasing_off = MoveStep()
608
+ """Stop walking through everything."""
609
+ stop_animation = MoveStep()
610
+ """Stop the walking animation."""
611
+ start_animation = MoveStep()
612
+ """Animate the walking again."""
613
+ transparency_up = MoveStep()
614
+ """One step more transparent (0 = opaque, 7 = most)."""
615
+ transparency_down = MoveStep()
616
+ """One step less transparent."""
617
+
618
+
619
+ def switch_on(switch: Fixed | Switch) -> MoveStep:
620
+ """Move step: turn a switch ON: ``switch_on(switches.door_open)``."""
621
+ return MoveStep()
622
+
623
+
624
+ def switch_off(switch: Fixed | Switch) -> MoveStep:
625
+ """Move step: turn a switch OFF: ``switch_off(switches.door_open)``."""
626
+ return MoveStep()
627
+
628
+
629
+ def change_graphic(charset: str, index: SpriteIndex | Dynamic) -> MoveStep:
630
+ """Move step: change the character's graphic to character ``index`` (0-7,
631
+ see SpriteIndex) of the CharSet image ``charset`` (file name without
632
+ extension)."""
633
+ return MoveStep()
634
+
635
+
636
+ # play_se(name, volume, tempo, balance) is a move step too (see Audio).
637
+
638
+
639
+ def move(code: int) -> MoveStep:
640
+ """Move step by its raw code (for codes rpgsync has no name for)."""
641
+ return MoveStep()
642
+
643
+
644
+ class Character:
645
+ """A character on the map: ``this``, ``player``, ``events[id]``, vehicles."""
646
+
647
+ map_id: Value
648
+ x: Value
649
+ y: Value
650
+ direction: Value
651
+ screen_x: Value
652
+ screen_y: Value
653
+ facing: Direction
654
+ """Test with ``this.facing == "up"``."""
655
+
656
+ def move(
657
+ self, *steps: MoveStep, frequency: Frequency | Dynamic = 6, repeat: bool = False, skippable: bool = False
658
+ ) -> None:
659
+ """Move Event: give the character a route to follow.
660
+
661
+ Between ``jump_start`` and ``jump_end`` only movement steps count.
662
+ Speed can only change relative to the current one (speed_up /
663
+ speed_down).
664
+
665
+ Args:
666
+ steps: the route, e.g. ``move_up * 3, face_left``.
667
+ frequency: 1 (slow) to 8 (continuous); affects moving, turning and waiting.
668
+ repeat: loop the route forever.
669
+ skippable: skip steps that cannot be done (blocked) instead of waiting.
670
+ """
671
+
672
+ def set_location(self, x: Number, y: Number, direction: TeleportDirection = "retain") -> None:
673
+ """Set Event Location: move this event instantly. x and y are both
674
+ numbers or both variables[id]."""
675
+
676
+ def show_animation(self, animation: Fixed, wait: bool = False, whole_map: bool = False) -> None:
677
+ """Show Battle Animation on this character (also works outside battle).
678
+
679
+ Args:
680
+ animation: animation id of the database.
681
+ wait: wait until the animation ends.
682
+ whole_map: play it over the whole screen instead of the character.
683
+ """
684
+
685
+ def call(self, page: Number) -> None:
686
+ """Call Event: run one page of this map event and wait for it."""
687
+
688
+ def flash(
689
+ self,
690
+ red: Fixed | None = None,
691
+ green: Fixed | None = None,
692
+ blue: Fixed | None = None,
693
+ strength: Fixed | None = None,
694
+ duration: float | None = None,
695
+ wait: bool | None = None,
696
+ extra: Extra = (),
697
+ ) -> None:
698
+ """Flash the character with a colour.
699
+
700
+ Args:
701
+ red, green, blue: colour, 0-31 each (default 31).
702
+ strength: 0-31 (default 31).
703
+ duration: seconds, in steps of 0.1 (default 0.5).
704
+ wait: wait until the flash ends.
705
+ """
706
+
707
+
708
+ class ThisEvent(Character):
709
+ def erase(self) -> None:
710
+ """Erase Event: remove this event until the player re-enters the map."""
711
+
712
+
713
+ class PlayerCharacter(Character):
714
+ vehicle: Vehicle | None
715
+ """Test with ``player.vehicle == "boat"``."""
716
+ visible: bool
717
+ """Assign to hide or show the hero (``player.visible = False``)."""
718
+
719
+
720
+ class VehicleCharacter(Character):
721
+ def set_sprite(self, charset: str, index: Fixed | None = None, *, extra: Extra = ()) -> None:
722
+ """Change the vehicle's graphic (CharSet name and character 0-7)."""
723
+
724
+
725
+ class Events:
726
+ def __getitem__(self, key: int | Variable) -> Character: ...
727
+
728
+
729
+ class CommonEvent:
730
+ def __call__(self) -> None:
731
+ """Call this common event and wait for it to end."""
732
+
733
+
734
+ class CommonEvents:
735
+ def __getitem__(self, key: Fixed) -> CommonEvent: ...
736
+
737
+
738
+ class CommonEventTable(CommonEvents):
739
+ """The common events of database/common_events.py: its @common_event
740
+ functions, called as ``common_events.name()`` (``common_events[10]()``
741
+ works too). The nested ``class Config:`` holds ``size``, the number of
742
+ slots the editor shows."""
743
+
744
+
745
+ class CommonEventFunction:
746
+ """A function decorated with @common_event: ``common_events.name()`` calls it."""
747
+
748
+ @overload
749
+ def __get__(self, obj: None, owner: type, /) -> CommonEventFunction: ...
750
+ @overload
751
+ def __get__(self, obj: object, owner: type, /) -> CommonEvent: ...
752
+ def __get__(self, obj: object, owner: type, /) -> CommonEventFunction | CommonEvent:
753
+ return CommonEvent()
754
+
755
+
756
+ class TroopEventTable:
757
+ """The battle events of database/troop_events.py: one @troop function per
758
+ monster group that has some, holding its @page functions."""
759
+
760
+
761
+ class Percent(Value):
762
+ """``percent(n)``: n% of the target's HP."""
763
+
764
+
765
+ class Enemy:
766
+ """``enemies[i]``: an enemy of the current battle (troop member)."""
767
+
768
+ hp: Value
769
+ sp: Value
770
+ max_hp: Value
771
+ max_sp: Value
772
+ attack: Value
773
+ defense: Value
774
+ spirit: Value
775
+ agility: Value
776
+ can_act: Condition
777
+ """In ``battle_condition(...)``: the enemy can act."""
778
+ targeted: Condition
779
+ """In ``battle_condition(...)``: the enemy is the current target."""
780
+
781
+ def hp_percent(self, min: int = 0, max: int = 100) -> Condition:
782
+ """Troop page condition: the enemy's HP is between min% and max% of its max HP."""
783
+
784
+ def turn(self, start: int, every: int = 0) -> Condition:
785
+ """Troop page condition (2003): the enemy's own turn count is ``start``, then
786
+ every ``every`` turns (``every=0``: that turn only)."""
787
+
788
+ def change_hp(self, amount: Number | Percent, lethal: bool | None = None, extra: Extra = ()) -> None:
789
+ """Change the enemy's HP (negative = damage); ``percent(n)`` changes
790
+ by n% of its HP. It cannot die unless ``lethal=True``."""
791
+
792
+ def change_sp(self, amount: Number, extra: Extra = ()) -> None:
793
+ """Change the enemy's SP (negative = lose)."""
794
+
795
+ def add_state(self, state: Fixed, *, extra: Extra = ()) -> None:
796
+ """Inflict a state on the enemy."""
797
+
798
+ def remove_state(self, state: Fixed, *, extra: Extra = ()) -> None:
799
+ """Cure a state of the enemy."""
800
+
801
+ def show(self, *, extra: Extra = ()) -> None:
802
+ """Make a hidden enemy appear."""
803
+
804
+
805
+ class Enemies:
806
+ def __getitem__(self, key: Fixed) -> Enemy: ...
807
+
808
+
809
+ class Picture:
810
+ """``pictures[id]``: one of the screen pictures. Pictures with a higher
811
+ number are drawn on top; coordinates are the picture's centre."""
812
+
813
+ def show(
814
+ self,
815
+ name: str,
816
+ *,
817
+ x: Number = 0,
818
+ y: Number = 0,
819
+ scroll_with_map: bool | None = None,
820
+ magnify: Fixed | None = None,
821
+ transparency: Fixed | None = None,
822
+ transparent_color: bool | None = None,
823
+ red: Fixed | None = None,
824
+ green: Fixed | None = None,
825
+ blue: Fixed | None = None,
826
+ saturation: Fixed | None = None,
827
+ effect: PictureEffect | None = None,
828
+ effect_power: Fixed | None = None,
829
+ bottom_transparency: Fixed | None = None,
830
+ extra: Extra = (),
831
+ ) -> None:
832
+ """Show Picture.
833
+
834
+ Args:
835
+ name: image of the Picture folder.
836
+ x, y: centre position in pixels; both numbers or both variables[id].
837
+ scroll_with_map: move with the map instead of staying on screen.
838
+ magnify: zoom in percent (100 = normal). Avoid scrolling the map
839
+ with a picture zoomed below 2%: RPG_RT can crash.
840
+ transparency: 0 (opaque) to 100 (invisible).
841
+ transparent_color: draw the image's transparent colour as transparent.
842
+ red, green, blue, saturation: tint, 0-200 (100 = unchanged).
843
+ effect: none, rotation or wave.
844
+ effect_power: speed of the rotation / strength of the wave.
845
+ bottom_transparency: transparency of the lower half (2003; defaults to transparency).
846
+ """
847
+
848
+ def move(
849
+ self,
850
+ *,
851
+ x: Number = 0,
852
+ y: Number = 0,
853
+ magnify: Fixed | None = None,
854
+ transparency: Fixed | None = None,
855
+ red: Fixed | None = None,
856
+ green: Fixed | None = None,
857
+ blue: Fixed | None = None,
858
+ saturation: Fixed | None = None,
859
+ effect: PictureEffect | None = None,
860
+ effect_power: Fixed | None = None,
861
+ duration: float | None = None,
862
+ wait: bool | None = None,
863
+ bottom_transparency: Fixed | None = None,
864
+ p4: Fixed | None = None,
865
+ p7: Fixed | None = None,
866
+ extra: Extra = (),
867
+ ) -> None:
868
+ """Move Picture: change position, zoom, transparency or tint over time.
869
+
870
+ Args:
871
+ x, y: new centre position (both numbers or both variables[id]).
872
+ duration: seconds, in steps of 0.1.
873
+ wait: wait until the move ends.
874
+ (other arguments: as in show(); p4/p7 are unused raw parameters)
875
+ """
876
+
877
+ def erase(self, extra: Extra = ()) -> None:
878
+ """Erase Picture."""
879
+
880
+
881
+ class Pictures:
882
+ def __getitem__(self, key: Fixed) -> Picture: ...
883
+
884
+
885
+ class Party:
886
+ """The hero party."""
887
+
888
+ gold: Counter
889
+ """``party.gold += 100``, ``if party.gold >= 100:``"""
890
+ size: Value
891
+ """Number of heroes in the party."""
892
+
893
+ def add(self, actor: Actor) -> None:
894
+ """Add a hero to the party (up to 4)."""
895
+
896
+ def remove(self, actor: Actor) -> None:
897
+ """Remove a hero from the party."""
898
+
899
+ def __contains__(self, member: Item | Actor) -> bool:
900
+ """``items[3] in party`` (holds the item) / ``actors[2] in party``."""
901
+
902
+
903
+ class Timer:
904
+ """``timer1`` / ``timer2`` (2003): a countdown shown on screen."""
905
+
906
+ seconds: Value
907
+ """Seconds left; test with ``timer1.seconds <= 10``."""
908
+
909
+ def set(self, seconds: Number, visible: bool | None = None, in_battle: bool | None = None) -> None:
910
+ """Set the timer's start value (it does not start yet)."""
911
+
912
+ def start(self, seconds: Number | None = None, visible: bool | None = None, in_battle: bool | None = None) -> None:
913
+ """Start the countdown.
914
+
915
+ Args:
916
+ visible: show the timer on screen.
917
+ in_battle: keep counting during battles.
918
+ seconds: raw value stored with the command (unused by RPG Maker).
919
+ """
920
+
921
+ def stop(self, seconds: Number | None = None, visible: bool | None = None, in_battle: bool | None = None) -> None:
922
+ """Stop the countdown."""
923
+
924
+
925
+ class GameState:
926
+ """Game-wide statistics and permissions."""
927
+
928
+ save_count: Value
929
+ battle_count: Value
930
+ win_count: Value
931
+ defeat_count: Value
932
+ escape_count: Value
933
+ midi_ticks: Value
934
+ """Position in the current MIDI music."""
935
+ allow_teleport: bool
936
+ """Assign to allow/forbid teleport skills."""
937
+ allow_escape: bool
938
+ """Assign to allow/forbid escape skills."""
939
+ allow_save: bool
940
+ """Assign to allow/forbid saving from the menu."""
941
+ allow_menu: bool
942
+ """Assign to allow/forbid opening the main menu."""
943
+
944
+
945
+ class DynToken:
946
+ """A DynRPG variable/actor token: ``V[12]`` is written ``V12`` in the comment."""
947
+
948
+
949
+ class _DynTokenPrefix:
950
+ def __getitem__(self, number: int) -> DynToken: ...
951
+
952
+
953
+ class Word:
954
+ """Unquoted text in a DynRPG call, written as is in the comment: ``word.end`` is
955
+ the ``end`` of ``@remove_text "id", end``; ``word(" Page 2")`` (a text that is no
956
+ Python name) keeps the spaces of ``@dynparams_append_string Page 2``. A word
957
+ can't hold ``"``, ``,`` or a line break. DynRPG gives most plugins a word
958
+ without its spaces, in lowercase: give texts as ``"strings"``. A plugin's own
959
+ word is written the way the plugin reads it: ``word.fixed`` of ``dyn.write_text``
960
+ is the ``"fixed"`` DynText compares."""
961
+
962
+
963
+ class _Words:
964
+ def __getattr__(self, text: str) -> Word: ...
965
+ def __call__(self, text: str, /) -> Word: ...
966
+
967
+
968
+ DynNumber = int | float | Variable | DynToken
969
+ """A number in a DynRPG call: ``12``, ``variables.x`` (read when the call runs),
970
+ ``variables[variables.x]`` or a token like ``v[12]``."""
971
+ DynString = str | DynToken
972
+ """A text in a DynRPG call: ``"text"``, ``actors[3].name`` (read when the call runs)
973
+ or a token like ``n[3]``."""
974
+ DynArg = DynNumber | DynString | Word
975
+ """Any argument of a DynRPG call."""
976
+
977
+
978
+ class DynRPG:
979
+ """DynRPG plugin calls, stored as "@function args" comments:
980
+ ``dyn.change_text("id", r"\\v[1]", 0)``, ``dyn.dynparams_add_param(2, variables.clue)``.
981
+ Arguments are numbers, strings, ``variables[...]``, ``actors[...].name``, tokens like
982
+ ``v[12]`` or words (``word.end``).
983
+
984
+ The commands of the plugins rpgsync knows are below; ``rpgsync check`` warns about
985
+ their arguments and, from DynPlugins/, about calls no plugin of the game runs. Any
986
+ other plugin's command works too: ``dyn.any_name(...)``. A plugin version may read
987
+ more arguments than written here: they are accepted."""
988
+
989
+ def __getattr__(self, function: str) -> Callable[..., None]: ...
990
+
991
+ # DynTextPlugin.dll: texts drawn on the screen. In the id and the text: \v[n]
992
+ # (variable), \n[n] (hero name), \i[n] / \I[n] (item name / description),
993
+ # \t[n] / \T[n] (skill name / description), \x[id] (another text)
994
+
995
+ def write_text(
996
+ self,
997
+ id: DynString,
998
+ x: DynNumber,
999
+ y: DynNumber,
1000
+ text: DynString | DynNumber,
1001
+ fixed: DynArg = ...,
1002
+ color: DynNumber = ...,
1003
+ picture: DynNumber = ...,
1004
+ /,
1005
+ *rest: DynArg,
1006
+ ) -> None:
1007
+ """DynTextPlugin: show a text at (x, y), drawn above a picture, while it shows
1008
+ (with its transparency): ``dyn.write_text("gold", 10, 10, r"\\v[4] G", 0, 3)``.
1009
+
1010
+ Args:
1011
+ fixed: ``word.fixed`` (written ``"fixed"``, as the plugin reads it) scrolls the
1012
+ text with the map; 0: it stays on screen.
1013
+ color: 0-19, a color of the system graphic.
1014
+ picture: the picture it goes with (default: PictureID in DynRPG.ini).
1015
+ """
1016
+
1017
+ def append_line(self, id: DynString, text: DynString | DynNumber, end: DynArg = ..., /, *rest: DynArg) -> None:
1018
+ """DynTextPlugin: add a line below a text."""
1019
+
1020
+ def append_text(self, id: DynString, text: DynString | DynNumber, end: DynArg = ..., /, *rest: DynArg) -> None:
1021
+ """DynTextPlugin: add to the end of a text's last line."""
1022
+
1023
+ def change_text(
1024
+ self, id: DynString, text: DynString | DynNumber, color: DynNumber | Word, /, *rest: DynArg
1025
+ ) -> None:
1026
+ """DynTextPlugin: replace a text; ``color``: 0-19, or ``word.end`` to keep it."""
1027
+
1028
+ def change_position(self, id: DynString, x: DynNumber, y: DynNumber, /, *rest: DynArg) -> None:
1029
+ """DynTextPlugin: move a text to (x, y)."""
1030
+
1031
+ def remove_text(self, id: DynString, end: DynArg = ..., /, *rest: DynArg) -> None:
1032
+ """DynTextPlugin: erase a text (``dyn.remove_text("id", word.end)``)."""
1033
+
1034
+ def remove_all(self, /, *rest: DynArg) -> None:
1035
+ """DynTextPlugin: erase every text."""
1036
+
1037
+ # DynParams.dll: rewrites the parameters of the next command (rpgsync writes these
1038
+ # comments for a variable where RPG Maker takes a number, see the README)
1039
+
1040
+ def dynparams_add_param(self, index: DynNumber, value: DynNumber = ..., /, *rest: DynArg) -> None:
1041
+ """DynParams: parameter ``index`` (from 1) of the next command := ``value``; with
1042
+ one number, it is the value of the next parameter (5, 6... or from set_index)."""
1043
+
1044
+ def dynparams_set_index(self, index: DynNumber, /, *rest: DynArg) -> None:
1045
+ """DynParams: the parameter ``dynparams_add_param(value)`` writes next."""
1046
+
1047
+ def dynparams_append_string(self, text: Word | DynString, /, *rest: DynArg) -> None:
1048
+ """DynParams: add to the text of the next command; the comment's text after the
1049
+ name, as is: ``word("Simu-Com 0")``."""
1050
+
1051
+ def dynparams_append_number(self, value: DynNumber, /, *rest: DynArg) -> None:
1052
+ """DynParams: add a number to the text of the next command."""
1053
+
1054
+ def dynparams_message_line_append_string(self, line: DynNumber, text: DynString, /, *rest: DynArg) -> None:
1055
+ """DynParams: add to line 1-4 of the next message."""
1056
+
1057
+ def dynparams_message_line_append_number(self, line: DynNumber, value: DynNumber, /, *rest: DynArg) -> None:
1058
+ """DynParams: add a number to line 1-4 of the next message."""
1059
+
1060
+ def dynparams_choice_case_append_string(self, choice: DynNumber, text: DynString, /, *rest: DynArg) -> None:
1061
+ """DynParams: add to a choice (from 1) of the next Show Choices."""
1062
+
1063
+ def dynparams_choice_case_append_number(self, choice: DynNumber, value: DynNumber, /, *rest: DynArg) -> None:
1064
+ """DynParams: add a number to a choice (from 1) of the next Show Choices."""
1065
+
1066
+ def dynparams_overwrite_next(self, /, *rest: DynArg) -> None:
1067
+ """DynParams: apply what the calls before built to the next command."""
1068
+
1069
+ def dynparams_clear_params(self, /, *rest: DynArg) -> None:
1070
+ """DynParams: forget what the calls before built."""
1071
+
1072
+ def dynparams_list_params(self, /, *rest: DynArg) -> None:
1073
+ """DynParams: show what the calls before built (a message box)."""
1074
+
1075
+ def dynparams_start_record(self, /, *rest: DynArg) -> None:
1076
+ """DynParams: write each command that runs into DynPlugins/DynParamsRecord.txt."""
1077
+
1078
+ def dynparams_stop_record(self, /, *rest: DynArg) -> None:
1079
+ """DynParams: stop writing DynPlugins/DynParamsRecord.txt."""
1080
+
1081
+ # msg_commands.dll
1082
+
1083
+ def process_cmd(self, /, *rest: DynArg) -> None:
1084
+ """msg_commands."""
1085
+
1086
+ # EasyRPG Player's own commands (no DLL; "easyrpg" in the patches)
1087
+
1088
+ def call(self, function: Word | DynString, /, *args: DynArg) -> None:
1089
+ """EasyRPG Player: run a command with the other arguments:
1090
+ ``dyn.call(word.easyrpg_add, 5, 1, 2)``."""
1091
+
1092
+ def easyrpg_output(self, mode: Word | DynString, message: DynString, /, *args: DynArg) -> None:
1093
+ """EasyRPG Player: write a message to its log; ``mode``: ``word.Debug``, ``word.Info``,
1094
+ ``word.Warning`` or ``word.Error``; ``$1``-``$9`` in it: the arguments after it."""
1095
+
1096
+ def easyrpg_add(self, variable: DynNumber, value: DynNumber, /, *values: DynNumber) -> None:
1097
+ """EasyRPG Player: variable number ``variable`` := the sum of the values."""
1098
+
1099
+
1100
+ ManiacValue = int | Value | Switch
1101
+ """A Maniac value: a number, ``variables[n]``, ``variables[variables[n]]`` or
1102
+ ``switches[n]`` (1 when ON)."""
1103
+
1104
+
1105
+ class ManiacPatch:
1106
+ """Maniac Patch commands (add "maniac" to ``patches`` in pyproject.toml).
1107
+
1108
+ Every Maniac command is written ``maniac.name(...)``. Commands with a
1109
+ known layout take named arguments; any command can also be written with
1110
+ its raw parameters as positional numbers: ``maniac.control_strings(0, 1, 2,
1111
+ text="...")``. rpgsync writes the raw form when a command's parameters
1112
+ don't fit its named form."""
1113
+
1114
+ def get_save_info(
1115
+ self,
1116
+ *params: int,
1117
+ slot: ManiacValue = 0,
1118
+ leader_name: bool = False,
1119
+ date: Variable = ...,
1120
+ time: Variable = ...,
1121
+ level: Variable = ...,
1122
+ hp: Variable = ...,
1123
+ name_string: Fixed = 0,
1124
+ face1: ManiacValue = 0,
1125
+ face2: ManiacValue = 0,
1126
+ face3: ManiacValue = 0,
1127
+ face4: ManiacValue = 0,
1128
+ extra: Extra = (),
1129
+ text: str = "",
1130
+ ) -> None:
1131
+ """Read a save's title data: date (YYMMDD, 0 = no save), time (HHMMSS), first hero's level and HP; leader_name also copies the leader's name into string name_string; faces go into pictures face1-face4 (0 = none; the four share how they are given). (3001)"""
1132
+
1133
+ def save(
1134
+ self,
1135
+ *params: int,
1136
+ slot: ManiacValue = 0,
1137
+ result: Variable | None = None,
1138
+ use_result: bool = True,
1139
+ extra: Extra = (),
1140
+ text: str = "",
1141
+ ) -> None:
1142
+ """Save into a slot (1 and up); result gets 1 on success, 0 on failure. (3002)"""
1143
+
1144
+ def load(
1145
+ self,
1146
+ *params: int,
1147
+ slot: ManiacValue = 0,
1148
+ skip_check: bool = False,
1149
+ no_blackout: bool = False,
1150
+ extra: Extra = (),
1151
+ text: str = "",
1152
+ ) -> None:
1153
+ """Load a slot; skip_check loads without checking the file first. (3003)"""
1154
+
1155
+ def end_load_process(self, *params: int, extra: Extra = (), text: str = "") -> None:
1156
+ """End the dark state after a load (obsolete). (3004)"""
1157
+
1158
+ def get_mouse_position(
1159
+ self, *params: int, x: Variable = ..., y: Variable = ..., extra: Extra = (), text: str = ""
1160
+ ) -> None:
1161
+ """The mouse position in 320 x 240 coordinates. (3005)"""
1162
+
1163
+ def set_mouse_position(
1164
+ self, *params: int, x: ManiacValue = 0, y: ManiacValue = 0, extra: Extra = (), text: str = ""
1165
+ ) -> None:
1166
+ """Move the mouse (x and y share how they are given). (3006)"""
1167
+
1168
+ def show_string_picture(self, *params: int, extra: Extra = (), text: str = "") -> None:
1169
+ """Show a picture made of text (raw parameters; text is \\x01TEXT\\x01SYSTEM\\x01FONT). (3007)"""
1170
+
1171
+ def get_picture_info(
1172
+ self,
1173
+ *params: int,
1174
+ info: Literal["original_size", "current_size", "target"] = "original_size",
1175
+ origin: Literal["center", "top_left", "edges"] = "center",
1176
+ picture: ManiacValue = 0,
1177
+ x: Variable = ...,
1178
+ y: Variable = ...,
1179
+ width: Variable = ...,
1180
+ height: Variable = ...,
1181
+ extra: Extra = (),
1182
+ text: str = "",
1183
+ ) -> None:
1184
+ """Position and size of a picture: info original_size / current_size / target; origin center / top_left / edges (left, top, right, bottom). (3008)"""
1185
+
1186
+ def control_battle(
1187
+ self,
1188
+ *params: int,
1189
+ hook: Literal["atb", "damage", "targeting", "state", "stat_change"] = "atb",
1190
+ common_event: ManiacValue = 0,
1191
+ first_var: Variable = ...,
1192
+ extra: Extra = (),
1193
+ text: str = "",
1194
+ ) -> None:
1195
+ """Battle hooks: call common_event at each atb / damage / targeting / state / stat_change, values passed through variables from first_var. (3009)"""
1196
+
1197
+ def control_atb_gauge(
1198
+ self,
1199
+ *params: int,
1200
+ target: Literal["actor", "member", "party", "enemy", "troop"] = "actor",
1201
+ target_id: ManiacValue = 0,
1202
+ op: Literal["set", "add", "sub"] = "set",
1203
+ unit: Literal["value", "percent"] = "value",
1204
+ value: ManiacValue = 0,
1205
+ extra: Extra = (),
1206
+ text: str = "",
1207
+ ) -> None:
1208
+ """Set, add to or subtract from an ATB gauge (0-300000, or percent). (3010)"""
1209
+
1210
+ def change_battle_command_ex(
1211
+ self,
1212
+ *params: int,
1213
+ disable_row: bool = False,
1214
+ no_fight: bool = False,
1215
+ no_auto: bool = False,
1216
+ no_escape: bool = False,
1217
+ win: bool = False,
1218
+ lose: bool = False,
1219
+ extra: Extra = (),
1220
+ text: str = "",
1221
+ ) -> None:
1222
+ """Battle commands: disable the row command, remove fight / auto / escape, add win / lose. (3011)"""
1223
+
1224
+ def get_battle_info(
1225
+ self,
1226
+ *params: int,
1227
+ target: Literal["actor", "member", "party", "enemy", "troop"] = "actor",
1228
+ info: Fixed = 0,
1229
+ target_id: ManiacValue = 0,
1230
+ first_var: Variable = ...,
1231
+ extra: Extra = (),
1232
+ text: str = "",
1233
+ ) -> None:
1234
+ """Battle information into variables from first_var. (3012)"""
1235
+
1236
+ def control_var_array(
1237
+ self,
1238
+ *params: int,
1239
+ op: Literal[
1240
+ "copy",
1241
+ "swap",
1242
+ "sort",
1243
+ "sort_descending",
1244
+ "shuffle",
1245
+ "enumerate",
1246
+ "add",
1247
+ "sub",
1248
+ "mul",
1249
+ "div",
1250
+ "mod",
1251
+ "or",
1252
+ "and",
1253
+ "xor",
1254
+ "shl",
1255
+ "shr",
1256
+ ] = "copy",
1257
+ a: ManiacValue = 0,
1258
+ length: ManiacValue = 0,
1259
+ b: ManiacValue = 0,
1260
+ extra: Extra = (),
1261
+ text: str = "",
1262
+ ) -> None:
1263
+ """Operate on variable arrays: a (length variables from id a) with b (ids are numbers, or variables[n] for an id read from a variable). (3013)"""
1264
+
1265
+ def key_input_proc_ex(
1266
+ self,
1267
+ *params: int,
1268
+ op: Literal["keyboard", "keyboard_raw", "key", "joypad", "joypad_raw", "remap_joypad"] = "keyboard",
1269
+ output: Variable = ...,
1270
+ key: ManiacValue = 0,
1271
+ extra: Extra = (),
1272
+ text: str = "",
1273
+ ) -> None:
1274
+ """Keyboard / joypad state into variables (op key: one key, given by key code). (3014)"""
1275
+
1276
+ def rewrite_map(
1277
+ self,
1278
+ *params: int,
1279
+ tiles_from_vars: bool = False,
1280
+ layer: Literal["lower", "upper"] = "lower",
1281
+ tile: ManiacValue = 0,
1282
+ x: ManiacValue = 0,
1283
+ y: ManiacValue = 0,
1284
+ width: ManiacValue = 0,
1285
+ height: ManiacValue = 0,
1286
+ no_autotile: bool = False,
1287
+ extra: Extra = (),
1288
+ text: str = "",
1289
+ ) -> None:
1290
+ """Replace map tiles (until the map reloads); tiles_from_vars reads tile ids from variables starting at tile. (3015)"""
1291
+
1292
+ def control_global_save(
1293
+ self,
1294
+ *params: int,
1295
+ op: Literal["open", "close", "save", "save_close", "load_values", "store_values"] = "open",
1296
+ kind: Literal["switches", "variables"] = "switches",
1297
+ game_id: ManiacValue = 0,
1298
+ global_id: ManiacValue = 0,
1299
+ count: ManiacValue = 0,
1300
+ extra: Extra = (),
1301
+ text: str = "",
1302
+ ) -> None:
1303
+ """Global save (Save.lgs) shared by every save: open, close, save, save_close, load_values / store_values switches or variables. (3016)"""
1304
+
1305
+ def change_picture_id(
1306
+ self,
1307
+ *params: int,
1308
+ op: Literal["move", "swap", "slide"] = "move",
1309
+ first: ManiacValue = 0,
1310
+ count: ManiacValue = 0,
1311
+ target: ManiacValue = 0,
1312
+ ignore_out_of_range: bool = False,
1313
+ extra: Extra = (),
1314
+ text: str = "",
1315
+ ) -> None:
1316
+ """Renumber pictures: move, swap or slide count pictures from first. (3017)"""
1317
+
1318
+ def set_game_option(
1319
+ self,
1320
+ *params: int,
1321
+ option: Literal[
1322
+ "run_when_inactive",
1323
+ "fps",
1324
+ "picture_limit",
1325
+ "frame_skip",
1326
+ "mouse_messages",
1327
+ "battle_origin",
1328
+ "battle_animation_limit",
1329
+ "face_size",
1330
+ ] = "run_when_inactive",
1331
+ value: ManiacValue = 0,
1332
+ value2: Fixed = 0,
1333
+ extra: Extra = (),
1334
+ text: str = "",
1335
+ ) -> None:
1336
+ """Game options: run_when_inactive, fps, picture_limit, frame_skip, mouse_messages, battle_origin, battle_animation_limit, face_size. (3018)"""
1337
+
1338
+ def call_command(self, *params: int, extra: Extra = (), text: str = "") -> None:
1339
+ """Run any event command (raw parameters). (3019)"""
1340
+
1341
+ def control_strings(self, *params: int, extra: Extra = (), text: str = "") -> None:
1342
+ """String variables: assign, append, convert, search, split... (raw parameters). (3020)"""
1343
+
1344
+ def get_game_info(self, *params: int, extra: Extra = (), text: str = "") -> None:
1345
+ """Map, screen, tile, interpreter, face, BGM information into variables (raw parameters). (3021)"""
1346
+
1347
+ def edit_picture(
1348
+ self,
1349
+ *params: int,
1350
+ picture: ManiacValue = 0,
1351
+ x: ManiacValue = 0,
1352
+ y: ManiacValue = 0,
1353
+ width: ManiacValue = 0,
1354
+ height: ManiacValue = 0,
1355
+ first_var: ManiacValue = 0,
1356
+ opaque: bool = False,
1357
+ keep_area: bool = False,
1358
+ extra: Extra = (),
1359
+ text: str = "",
1360
+ ) -> None:
1361
+ """Write pixels (ARGB values from variables from first_var) into a picture. (3025)"""
1362
+
1363
+ def write_picture(
1364
+ self,
1365
+ *params: int,
1366
+ name_from: Literal["text", "string", "string_ref"] = "text",
1367
+ target: Literal["screen", "picture"] = "screen",
1368
+ picture: ManiacValue = 0,
1369
+ name_string: Fixed = 0,
1370
+ dynamic: bool = False,
1371
+ opaque: bool = False,
1372
+ filename: str = "",
1373
+ extra: Extra = (),
1374
+ text: str = "",
1375
+ ) -> None:
1376
+ """Save the screen or a picture as an image file. (3026)"""
1377
+
1378
+ def add_move_route(self, *params: int, extra: Extra = (), text: str = "") -> None:
1379
+ """Maniac command (3027)"""
1380
+
1381
+ def edit_tile(
1382
+ self,
1383
+ *params: int,
1384
+ picture: ManiacValue = 0,
1385
+ x: ManiacValue = 0,
1386
+ y: ManiacValue = 0,
1387
+ width: ManiacValue = 0,
1388
+ height: ManiacValue = 0,
1389
+ tile: ManiacValue = 0,
1390
+ no_autotile: bool = False,
1391
+ clear: bool = False,
1392
+ tiles_from_vars: bool = False,
1393
+ layer: Literal["lower", "upper"] = "lower",
1394
+ tileset: ManiacValue = 0,
1395
+ pattern: ManiacValue = 0,
1396
+ extra: Extra = (),
1397
+ text: str = "",
1398
+ ) -> None:
1399
+ """Draw map tiles onto a picture. (3028)"""
1400
+
1401
+ def control_text_processing(
1402
+ self,
1403
+ *params: int,
1404
+ source: Literal["id", "variable", "variable_ref", "name", "string", "string_ref"] = "id",
1405
+ on_marker: bool = False,
1406
+ on_open: bool = False,
1407
+ on_close: bool = False,
1408
+ on_char: bool = False,
1409
+ event: Fixed = 0,
1410
+ info_var: Fixed = 0,
1411
+ info_string: Fixed = 0,
1412
+ number_args: Fixed = 0,
1413
+ string_args: Fixed = 0,
1414
+ name: str = "",
1415
+ extra: Extra = (),
1416
+ text: str = "",
1417
+ ) -> None:
1418
+ """Call a common event on message events: on_marker (the \\e text marker), on_open, on_close, on_char. (3029)"""
1419
+
1420
+ def script(self, *params: int, extra: Extra = (), text: str = "") -> None:
1421
+ """Run a Maniac script (raw parameters; text is the first line). (3030)"""
1422
+
1423
+ def script_line(self, *params: int, extra: Extra = (), text: str = "") -> None:
1424
+ """A following script line. (3031)"""
1425
+
1426
+ def zoom(
1427
+ self,
1428
+ *params: int,
1429
+ x: ManiacValue = 0,
1430
+ y: ManiacValue = 0,
1431
+ scale: ManiacValue = 0,
1432
+ duration: ManiacValue = 0,
1433
+ layer: ManiacValue = 0,
1434
+ wait: bool = False,
1435
+ extra: Extra = (),
1436
+ text: str = "",
1437
+ ) -> None:
1438
+ """Zoom the screen around x, y. (3032)"""
1439
+
1440
+ def console(self, *params: int, extra: Extra = (), text: str = "") -> None:
1441
+ """Text console (raw parameters). (3033)"""
1442
+
1443
+ def control_self_variable(self, *params: int, extra: Extra = (), text: str = "") -> None:
1444
+ """Control self variables, switches and strings (raw parameters). (3036)"""
1445
+
1446
+ def control_media_option(self, *params: int, extra: Extra = (), text: str = "") -> None:
1447
+ """Media options (raw parameters). (3038)"""
1448
+
1449
+ def __getattr__(self, command: str) -> Callable[..., None]:
1450
+ """Other Maniac commands, by name (control_strings, show_string_picture,
1451
+ command_3036, ...): raw parameters as positional numbers, text=..."""
1452
+ ...
1453
+
1454
+
1455
+ # `variables` and `switches` come from the game's database/variables.py and
1456
+ # database/switches.py (classes of rpgsync.tables), which name them.
1457
+ items = Items()
1458
+ actors = Actors()
1459
+ events = Events()
1460
+ """Events of the current map, by id."""
1461
+ enemies = Enemies()
1462
+ pictures = Pictures()
1463
+ party = Party()
1464
+ this = ThisEvent()
1465
+ """The event running the script."""
1466
+ player = PlayerCharacter()
1467
+ """The hero on the map."""
1468
+ boat = VehicleCharacter()
1469
+ ship = VehicleCharacter()
1470
+ airship = VehicleCharacter()
1471
+ timer1 = Timer()
1472
+ timer2 = Timer()
1473
+ game = GameState()
1474
+ dyn = DynRPG()
1475
+ maniac = ManiacPatch()
1476
+ V = VV = VVV = v = vv = vvv = N = NV = NVV = n = nv = nvv = _DynTokenPrefix()
1477
+ word = _Words()
1478
+ """Unquoted text in a DynRPG call: ``word.end``, ``word("Simu-Com Faceset 00")`` (see Word)."""
1479
+ started_by_action_key = Condition()
1480
+ """Condition: the event was started with the action key."""
1481
+ bgm_looped = Condition()
1482
+ """Condition: the current music has played through once (MIDI only; also
1483
+ true right after loading a save)."""
1484
+
1485
+
1486
+ def randint(a: Fixed, b: Fixed) -> Value:
1487
+ """A random number from a to b (inclusive), like random.randint."""
1488
+ return Value()
1489
+
1490
+
1491
+ def percent(value: Fixed) -> Percent:
1492
+ """n% of the target's HP, for enemies[i].change_hp()."""
1493
+ return Percent()
1494
+
1495
+
1496
+ def input_number(digits: Digits | Dynamic) -> Value:
1497
+ """Input Number: the player types a number.
1498
+
1499
+ ``variables[3] = input_number(digits=4)``
1500
+
1501
+ Args:
1502
+ digits: how many digits the player can type (1-6 in 2000, 1-7 in 2003,
1503
+ up to 9 with the Maniac Patch).
1504
+ """
1505
+ return Value()
1506
+
1507
+
1508
+ def terrain_id(x: Number, y: Number) -> Value:
1509
+ """The terrain id of a map tile: ``variables[5] = terrain_id(10, 4)``.
1510
+ Empty tiles give the chipset's first terrain (water)."""
1511
+ return Value()
1512
+
1513
+
1514
+ def event_id_at(x: Number, y: Number) -> Value:
1515
+ """The id of the event on a tile (the highest if several, 0 if none):
1516
+ ``variables[5] = event_id_at(this.x, this.y)``."""
1517
+ return Value()
1518
+
1519
+
1520
+ def key_input(
1521
+ *,
1522
+ wait: bool | Fixed = False,
1523
+ directions: bool | Fixed = False,
1524
+ decision: bool | Fixed = False,
1525
+ cancel: bool | Fixed = False,
1526
+ numbers: bool | Fixed = False,
1527
+ operators: bool | Fixed = False,
1528
+ time_variable: Variable | None = None,
1529
+ count_time: bool | Fixed = False,
1530
+ shift: bool | Fixed = False,
1531
+ down: bool | Fixed = False,
1532
+ left: bool | Fixed = False,
1533
+ right: bool | Fixed = False,
1534
+ up: bool | Fixed = False,
1535
+ layout: Literal[2000, 2003] | None = None,
1536
+ ) -> Value:
1537
+ """Key Input Processing: ``variables[148] = key_input(down=True, up=True, wait=True)``.
1538
+
1539
+ The variable receives the key pressed: 1 down, 2 left, 3 right, 4 up,
1540
+ 5 decision, 6 cancel, 7 shift, 10-19 numbers 0-9, 20-24 + - * / and .
1541
+ (0 when nothing was pressed).
1542
+
1543
+ Args:
1544
+ wait: wait until one of the keys is pressed.
1545
+ directions: all four arrows at once (older editor versions).
1546
+ decision, cancel, shift, down, left, right, up: keys to check.
1547
+ numbers, operators: number and operator keys (2003).
1548
+ time_variable: store the time taken, in tenths of a second (2003).
1549
+ count_time: whether time_variable is used.
1550
+ layout: parameter layout of another editor version (set by rpgsync).
1551
+ Flags may be integers when the Maniac Patch stores mouse buttons.
1552
+ """
1553
+ return Value()
1554
+
1555
+
1556
+ def cond(kind: int, a: int, b: int, c: int, d: int) -> Condition:
1557
+ """Any other Conditional Branch, by its raw parameters."""
1558
+ return Condition()
1559
+
1560
+
1561
+ def battle_condition(condition: Condition | bool) -> Condition:
1562
+ """A battle Conditional Branch (troop events): switches, variables,
1563
+ ``actors[id].can_act``, ``enemies[i].can_act``, ``enemies[i].targeted``,
1564
+ ``actors[id].uses_command(n)``. Example: ``if battle_condition(enemies[0].targeted):``"""
1565
+ return Condition()
1566
+
1567
+
1568
+ def turn(start: int, every: int = 0) -> Condition:
1569
+ """Troop page condition: the battle's turn count is ``start``, then every
1570
+ ``every`` turns: ``turn(0)`` is the start of the battle, ``turn(1, every=2)``
1571
+ turns 1, 3, 5... (``every=0``: that turn only)."""
1572
+ return Condition()
1573
+
1574
+
1575
+ def fatigue(min: int = 0, max: int = 100) -> Condition:
1576
+ """Troop page condition: the party's fatigue (exhaustion) is between min% and max%."""
1577
+ return Condition()
1578
+
1579
+
1580
+ # ==========================================================================
1581
+ # Structure
1582
+ # ==========================================================================
1583
+
1584
+
1585
+ class Route:
1586
+ """A custom move route for page(route=...)."""
1587
+
1588
+
1589
+ class Event(Character):
1590
+ """A map event: ``@event(30, "Gary", x=17, y=16)`` on ``class Gary(Event):``.
1591
+ The event is a character of the map: ``Gary.move(...)``, ``Gary.x``.
1592
+
1593
+ Its pages are its ``page_1(self)``, ``page_2(self)``... methods, numbered
1594
+ like the editor's tabs. The active page is the last one whose ``when=``
1595
+ holds; when none holds, the event is not on the map. ``Gary.page_3()``
1596
+ runs page 3 (Call Event); in Gary's pages, ``self`` is Gary.
1597
+
1598
+ The class attributes are the settings of every page, unless a page's
1599
+ ``@page(...)`` says otherwise; a page without ``@page`` has no condition
1600
+ and the class's settings. A page's docstring is its first comment in the
1601
+ game.
1602
+ """
1603
+
1604
+ sprite: tuple[str, SpriteIndex] | None = None
1605
+ """("CharSet", 0-7): the graphic of the pages (None: no graphic)."""
1606
+ tile: int | None = None
1607
+ """A tile of the chipset as the graphic of the pages, instead of a sprite."""
1608
+ pattern: Pattern = "middle"
1609
+ """Animation frame shown when standing still."""
1610
+ translucent: bool = False
1611
+ """Draw semi-transparent."""
1612
+ trigger: Trigger = "action"
1613
+ """How the pages start (action, touch, collision, autorun, parallel)."""
1614
+ layer: Layer = "below"
1615
+ """Below, same level as, or above the hero."""
1616
+ overlap_forbidden: bool = False
1617
+ """Other events cannot walk through it."""
1618
+ animation: AnimationType = "non_continuous"
1619
+ """How the sprite animates."""
1620
+ move_type: MoveType = "stationary"
1621
+ """Automatic movement; "custom" follows ``route``."""
1622
+ frequency: Frequency = 3
1623
+ """How often it moves (1-8)."""
1624
+ speed: Speed = 3
1625
+ """Movement speed (1 = 1/8 ... 4 = normal ... 6 = x4)."""
1626
+ # direction and route are set on each page: @page(direction="left", route=route(...))
1627
+
1628
+
1629
+ class _EventDecorator(Protocol):
1630
+ @overload
1631
+ def __call__(self, cls: type[_E], /) -> _E: ...
1632
+ @overload
1633
+ def __call__(self, fn: Callable[[], None], /) -> Character: ...
1634
+
1635
+
1636
+ def event(id: int | None = None, name: str = "", x: int = 0, y: int = 0) -> _EventDecorator:
1637
+ """A map event, on its class: ``@event(30, "Gary", x=17, y=16)`` then
1638
+ ``class Gary(Event):`` (see Event).
1639
+
1640
+ Args:
1641
+ id: event id; leave it out for a new event: the lowest free id is
1642
+ assigned and written back into the script.
1643
+ name: name shown in the editor.
1644
+ x, y: tile position on the map.
1645
+ """
1646
+ return lambda fn: fn # type: ignore[return-value]
1647
+
1648
+
1649
+ def page(
1650
+ *,
1651
+ when: Condition | bool | None = None,
1652
+ sprite: tuple[str, SpriteIndex] | None = None,
1653
+ tile: int | None = None,
1654
+ direction: Direction = "down",
1655
+ pattern: Pattern = "middle",
1656
+ translucent: bool = False,
1657
+ trigger: Trigger = "action",
1658
+ layer: Layer = "below",
1659
+ overlap_forbidden: bool = False,
1660
+ animation: AnimationType = "non_continuous",
1661
+ move_type: MoveType = "stationary",
1662
+ frequency: Frequency = 3,
1663
+ speed: Speed = 3,
1664
+ route: Route | None = None,
1665
+ id: int | None = None,
1666
+ raw: bool = False,
1667
+ switch_a: int | None = None,
1668
+ switch_b: int | None = None,
1669
+ variable: tuple[int, str, int] | None = None,
1670
+ item: int | None = None,
1671
+ actor: int | None = None,
1672
+ timer: int | None = None,
1673
+ timer2: int | None = None,
1674
+ ) -> Callable[[_F], _F]:
1675
+ """The condition and settings of an event page (a ``page_N`` function of
1676
+ the event's class). Pages are listed in order, page_1 first; the last page
1677
+ whose conditions hold is the active one. A setting left out is the class's
1678
+ (see Event), else the default below; a page with no condition and the
1679
+ class's settings needs no ``@page``.
1680
+
1681
+ Args:
1682
+ when: conditions joined with ``and``: up to two ``switches[id]``,
1683
+ ``variables[id] >= n`` (any comparison in 2003),
1684
+ ``items[id] in party``, ``actors[id] in party``,
1685
+ ``timer1.seconds <= n``, ``timer2.seconds <= n``.
1686
+ sprite: ("CharSet", 0-7), the event's graphic; the index counts the
1687
+ 8 characters of the image left to right, top to bottom (see
1688
+ SpriteIndex). ``sprite=None``: no graphic (when the class has one).
1689
+ tile: a tile of the chipset as graphic, instead of a sprite.
1690
+ direction: facing direction of the graphic.
1691
+ pattern: animation frame shown when standing still.
1692
+ translucent: draw semi-transparent.
1693
+ trigger: how the page starts (action, touch, collision, autorun, parallel).
1694
+ layer: below, same level as, or above the hero.
1695
+ overlap_forbidden: other events cannot walk through it.
1696
+ animation: how the sprite animates.
1697
+ move_type: automatic movement; "custom" follows ``route``.
1698
+ frequency: how often it moves (1-8).
1699
+ speed: movement speed (1 = 1/8 ... 4 = normal ... 6 = x4).
1700
+ route: route(...) followed when move_type="custom"; ``route=None``: no
1701
+ route (when the class has one).
1702
+ id: the page's stored number, when pages are not numbered 1, 2, 3...
1703
+ raw: the body is raw cmd(..., indent=N) lines (set by rpgsync).
1704
+ switch_b: the editor's second switch slot, for pages that leave the
1705
+ first one unchecked (``when`` puts a single switch in the first
1706
+ slot; both behave the same).
1707
+ switch_a, variable, item, actor, timer, timer2: the conditions in
1708
+ explicit form (used instead of ``when`` for rare combinations).
1709
+
1710
+ A battle event page of a troop (database/troop_events.py) only takes
1711
+ ``when``, ``switch_b``, ``id`` and ``raw``; its ``when`` joins with ``and``:
1712
+ up to two ``switches[id]``, ``variables[id] >= n``, ``turn(n, every=m)``,
1713
+ ``fatigue(min, max)``, ``enemies[i].hp_percent(min, max)``,
1714
+ ``actors[id].hp_percent(min, max)`` and, in 2003,
1715
+ ``enemies[i].turn(n, every=m)``, ``actors[id].turn(n, every=m)``,
1716
+ ``actors[id].uses_command(n)``. The page runs when they all hold.
1717
+ """
1718
+ return lambda fn: fn
1719
+
1720
+
1721
+ def common_event(
1722
+ id: int | None = None,
1723
+ name: str = "",
1724
+ trigger: CommonEventTrigger = "call",
1725
+ switch: int | None = None,
1726
+ raw: bool = False,
1727
+ ) -> Callable[[Callable[[], None]], CommonEventFunction]:
1728
+ """A common event of the database. Leave out the id for a new one.
1729
+
1730
+ Args:
1731
+ trigger: call (run with common_events[id]()), autorun or parallel.
1732
+ switch: condition switch of an autorun/parallel common event.
1733
+ raw: the body is raw cmd(...) lines (set by rpgsync).
1734
+ """
1735
+ return lambda fn: fn
1736
+
1737
+
1738
+ def troop(id: int, name: str = "") -> Callable[[Callable[[], None]], Callable[[], None]]:
1739
+ """The battle events of a troop (monster group), in database/troop_events.py:
1740
+ its @page functions, in order.
1741
+
1742
+ Args:
1743
+ id: the troop's id (its slot in database/troops.py, where troops are added).
1744
+ name: the troop's name, as a label: rename the troop in database/troops.py.
1745
+ """
1746
+ return lambda fn: fn
1747
+
1748
+
1749
+ def route(*steps: MoveStep, repeat: bool = True, skippable: bool = False) -> Route:
1750
+ """Custom move route: ``route(move_up * 2, move_down * 2, repeat=True)``."""
1751
+ return Route()
1752
+
1753
+
1754
+ # ==========================================================================
1755
+ # Messages
1756
+ # ==========================================================================
1757
+
1758
+
1759
+ def text(*lines: str, split: bool = True) -> None:
1760
+ """Show Message: one argument per line, up to 4 lines per box ("\\n" in an
1761
+ argument starts a new line; with split=False each argument is exactly one
1762
+ line, line breaks included).
1763
+
1764
+ Message codes: \\c[n] colour (0-19, from the System graphic), \\s[n] text
1765
+ speed (1 fastest - 20 slowest), \\v[n] variable value, \\n[n] hero name,
1766
+ \\$ gold window, \\. short pause, \\| long pause, \\! wait for a key,
1767
+ \\^ close automatically, \\> \\< show instantly. Use raw strings
1768
+ (r"...") so backslashes stay as typed."""
1769
+
1770
+
1771
+ def comment(*lines: str, split: bool = True) -> None:
1772
+ """An editor comment, kept in the game data. A full-line ``# text`` in a
1773
+ script does the same; DynRPG plugin calls are written ``dyn.function(...)``."""
1774
+
1775
+
1776
+ def face(faceset: str | None, index: Fixed | None = None, right: bool | None = None, flip: bool | None = None) -> None:
1777
+ """Set the face shown in messages (it narrows the text area).
1778
+
1779
+ Args:
1780
+ faceset: FaceSet image name, or None to remove the face.
1781
+ index: face in the image (0-15).
1782
+ right: show the face on the right side.
1783
+ flip: mirror the face.
1784
+ """
1785
+
1786
+
1787
+ def message_options(
1788
+ transparent: bool = False,
1789
+ position: MessagePosition = "bottom",
1790
+ avoid_hero: bool = False,
1791
+ continue_events: bool = False,
1792
+ ) -> None:
1793
+ """Message window settings.
1794
+
1795
+ Args:
1796
+ transparent: no window background.
1797
+ position: top, middle or bottom of the screen.
1798
+ avoid_hero: move the window so it never hides the hero (overrides position).
1799
+ continue_events: let other events run while a message is shown.
1800
+ """
1801
+
1802
+
1803
+ def show_choices(*options: str, cancel: CancelOption | Dynamic | None = None, summary: str | None = None) -> str:
1804
+ """Show Choices (up to 4), written as a match statement::
1805
+
1806
+ match show_choices("Yes", "No"):
1807
+ case "Yes": ...
1808
+ case "No": ...
1809
+ case _: ... # optional: separate cancel branch
1810
+
1811
+ When two options have the same text, the cases are the option
1812
+ numbers (``case 0:``, ``case 1:``).
1813
+
1814
+ Args:
1815
+ options: the texts of the choices.
1816
+ cancel: the option (1-4) chosen with the cancel key; None forbids
1817
+ cancelling, a ``case _:`` adds a separate cancel branch.
1818
+ summary: editor summary of the options, when it differs from the texts.
1819
+ """
1820
+ return ""
1821
+
1822
+
1823
+ # ==========================================================================
1824
+ # Party, heroes, items
1825
+ # ==========================================================================
1826
+
1827
+ ActorTarget = Actor | Party
1828
+ """``party`` (every hero of the party), ``actors[id]`` or ``actors[variables[id]]``."""
1829
+
1830
+
1831
+ def change_exp(actor: ActorTarget, amount: Number, message: bool = False) -> None:
1832
+ """Change Experience: ``change_exp(actors[1], 500)``, ``change_exp(party, -variables[3])``.
1833
+
1834
+ Args:
1835
+ message: show the level-up message.
1836
+ """
1837
+
1838
+
1839
+ def change_level(actor: ActorTarget, amount: Number, message: bool = False) -> None:
1840
+ """Change Level: ``change_level(party, 1, message=True)`` (negative lowers it)."""
1841
+
1842
+
1843
+ def change_stat(actor: ActorTarget, stat: Stat, amount: Number, *, extra: Extra = ()) -> None:
1844
+ """Permanently change a base stat: ``change_stat(actors[1], "attack", 5)``."""
1845
+
1846
+
1847
+ def change_hp(actor: ActorTarget, amount: Number, lethal: bool | None = None, *, extra: Extra = ()) -> None:
1848
+ """Change HP (negative = damage). Damage stops at 1 HP unless ``lethal=True``."""
1849
+
1850
+
1851
+ def change_sp(actor: ActorTarget, amount: Number, *, extra: Extra = ()) -> None:
1852
+ """Change SP (negative = lose)."""
1853
+
1854
+
1855
+ def full_heal(actor: ActorTarget) -> None:
1856
+ """Restore all HP and SP and cure all states."""
1857
+
1858
+
1859
+ def learn_skill(actor: ActorTarget, skill: Number, *, extra: Extra = ()) -> None:
1860
+ """Teach a skill."""
1861
+
1862
+
1863
+ def forget_skill(actor: ActorTarget, skill: Number, *, extra: Extra = ()) -> None:
1864
+ """Remove a skill."""
1865
+
1866
+
1867
+ def equip(actor: ActorTarget, item: Number, *, extra: Extra = ()) -> None:
1868
+ """Equip an item (taken from the inventory)."""
1869
+
1870
+
1871
+ def unequip(actor: ActorTarget, slot: EquipSlot, p4: Fixed | None = None, *, extra: Extra = ()) -> None:
1872
+ """Remove equipment from one slot or all of them."""
1873
+
1874
+
1875
+ def add_state(actor: ActorTarget, state: Fixed, *, extra: Extra = ()) -> None:
1876
+ """Inflict a state (dead, poison, sleep...)."""
1877
+
1878
+
1879
+ def remove_state(actor: ActorTarget, state: Fixed, *, extra: Extra = ()) -> None:
1880
+ """Cure a state."""
1881
+
1882
+
1883
+ def simulate_attack(
1884
+ actor: ActorTarget,
1885
+ attack: Fixed | None = None,
1886
+ defense: Fixed | None = None,
1887
+ spirit: Fixed | None = None,
1888
+ variance: Fixed | None = None,
1889
+ store_damage: Variable | None = None,
1890
+ use_store_damage: bool | None = None,
1891
+ *,
1892
+ extra: Extra = (),
1893
+ ) -> None:
1894
+ """Simulated Attack: deal damage as if attacked by an invisible enemy
1895
+ (can cause a game over).
1896
+
1897
+ Args:
1898
+ attack, defense, spirit: weights of the damage formula.
1899
+ variance: random variation (0-10).
1900
+ store_damage: also store the damage in this variable.
1901
+ """
1902
+
1903
+
1904
+ def change_class(
1905
+ actor: ActorTarget,
1906
+ class_id: Fixed,
1907
+ reset_level: bool | None = None,
1908
+ skills: SkillMode | None = None,
1909
+ stats: StatMode | None = None,
1910
+ message: bool | None = None,
1911
+ *,
1912
+ extra: Extra = (),
1913
+ ) -> None:
1914
+ """Change Class (2003): also changes base stats and battle commands.
1915
+
1916
+ Args:
1917
+ class_id: new class (0 = none).
1918
+ reset_level: back to level 1.
1919
+ skills: keep, replace with the class skills, or add them.
1920
+ stats: keep, halve, as at level 1, or as at the current level.
1921
+ message: show the learned-skills message.
1922
+ """
1923
+
1924
+
1925
+ def add_battle_command(actor: ActorTarget, command: Fixed, *, extra: Extra = ()) -> None:
1926
+ """Add a battle command to the hero's menu (2003)."""
1927
+
1928
+
1929
+ def remove_battle_command(actor: ActorTarget, command: Fixed, *, extra: Extra = ()) -> None:
1930
+ """Remove a battle command (2003); command 0 removes all."""
1931
+
1932
+
1933
+ def enter_hero_name(
1934
+ actor: Fixed | None, charset: Fixed | None = None, use_current_name: bool | None = None, *, extra: Extra = ()
1935
+ ) -> None:
1936
+ """Open the name entry screen.
1937
+
1938
+ Args:
1939
+ actor: hero id.
1940
+ charset: letter set of the entry screen.
1941
+ use_current_name: start from the current name instead of an empty one.
1942
+ """
1943
+
1944
+
1945
+ # ==========================================================================
1946
+ # System
1947
+ # ==========================================================================
1948
+
1949
+
1950
+ def set_system_bgm(
1951
+ context: BgmContext,
1952
+ name: str,
1953
+ fade: Fixed | None = None,
1954
+ volume: Fixed | None = None,
1955
+ tempo: Fixed | None = None,
1956
+ balance: Fixed | None = None,
1957
+ *,
1958
+ extra: Extra = (),
1959
+ ) -> None:
1960
+ """Change a system music (battle, victory, inn, vehicles, game over)."""
1961
+
1962
+
1963
+ def set_system_se(
1964
+ context: SeContext,
1965
+ name: str,
1966
+ volume: Fixed | None = None,
1967
+ tempo: Fixed | None = None,
1968
+ balance: Fixed | None = None,
1969
+ *,
1970
+ extra: Extra = (),
1971
+ ) -> None:
1972
+ """Change a system sound effect (cursor, decision, ...)."""
1973
+
1974
+
1975
+ def set_system_graphics(
1976
+ name: str,
1977
+ stretch: Literal["stretch", "tile"] | None = None,
1978
+ font: Literal["gothic", "mincho"] | None = None,
1979
+ *,
1980
+ extra: Extra = (),
1981
+ ) -> None:
1982
+ """Change the System graphic (windows, cursor, text colours)."""
1983
+
1984
+
1985
+ def set_transition(kind: TransitionKind, transition: Transition, *, extra: Extra = ()) -> None:
1986
+ """Change a default screen transition (teleport, battle start/end)."""
1987
+
1988
+
1989
+ # ==========================================================================
1990
+ # Map and movement
1991
+ # ==========================================================================
1992
+
1993
+
1994
+ def teleport(map: Fixed, x: Fixed, y: Fixed, direction: TeleportDirection = "retain") -> None:
1995
+ """Teleport the party to another map position."""
1996
+
1997
+
1998
+ def memorize_location(map: Variable, x: Variable, y: Variable, *, extra: Extra = ()) -> None:
1999
+ """Store the party's map id and position in three variables."""
2000
+
2001
+
2002
+ def recall_location(map: Variable, x: Variable, y: Variable, *, extra: Extra = ()) -> None:
2003
+ """Teleport the party to a position stored with memorize_location()."""
2004
+
2005
+
2006
+ def toggle_vehicle(*, extra: Extra = ()) -> None:
2007
+ """Get on / off the vehicle the hero faces."""
2008
+
2009
+
2010
+ def set_vehicle_location(
2011
+ vehicle: Literal["party", "boat", "ship", "airship"] | Fixed, # int: a value the editor cannot set
2012
+ map: Number,
2013
+ x: Number,
2014
+ y: Number,
2015
+ direction: TeleportDirection | None = None,
2016
+ *,
2017
+ extra: Extra = (),
2018
+ ) -> None:
2019
+ """Place a vehicle on a map (map, x and y: all numbers or all variables[id])."""
2020
+
2021
+
2022
+ def swap_events(first: Character, second: Character, *, extra: Extra = ()) -> None:
2023
+ """Swap the positions of two events of the map."""
2024
+
2025
+
2026
+ def set_tileset(chipset: Fixed, *, extra: Extra = ()) -> None:
2027
+ """Change the map's chipset (tileset)."""
2028
+
2029
+
2030
+ def set_panorama(
2031
+ name: str,
2032
+ scroll_x: bool | None = None,
2033
+ scroll_y: bool | None = None,
2034
+ auto_scroll_x: bool | None = None,
2035
+ speed_x: Fixed | None = None,
2036
+ auto_scroll_y: bool | None = None,
2037
+ speed_y: Fixed | None = None,
2038
+ *,
2039
+ extra: Extra = (),
2040
+ ) -> None:
2041
+ """Change the panorama (parallax background) of the map."""
2042
+
2043
+
2044
+ def set_encounter_rate(steps: Fixed, *, extra: Extra = ()) -> None:
2045
+ """Average number of steps between random battles (0 = none)."""
2046
+
2047
+
2048
+ def replace_tile(layer: Literal["lower", "upper"], old: Fixed, new: Fixed, *, extra: Extra = ()) -> None:
2049
+ """Replace every tile `old` by tile `new` on a layer of the map."""
2050
+
2051
+
2052
+ def add_teleport_target(
2053
+ map: Fixed, x: Fixed, y: Fixed, switch: Fixed | None = None, use_switch: bool | None = None, *, extra: Extra = ()
2054
+ ) -> None:
2055
+ """Add a destination for teleport skills (optionally turning a switch ON)."""
2056
+
2057
+
2058
+ def remove_teleport_target(
2059
+ map: Fixed,
2060
+ x: Fixed | None = None,
2061
+ y: Fixed | None = None,
2062
+ switch: Fixed | None = None,
2063
+ use_switch: bool | None = None,
2064
+ *,
2065
+ extra: Extra = (),
2066
+ ) -> None:
2067
+ """Remove a teleport skill destination."""
2068
+
2069
+
2070
+ def set_escape_target(
2071
+ map: Fixed, x: Fixed, y: Fixed, switch: Fixed | None = None, use_switch: bool | None = None, *, extra: Extra = ()
2072
+ ) -> None:
2073
+ """Set where escape skills lead (optionally turning a switch ON)."""
2074
+
2075
+
2076
+ def wait_for_movement() -> None:
2077
+ """Wait until all moving events finished their routes (except repeating ones)."""
2078
+
2079
+
2080
+ def halt_all_movement() -> None:
2081
+ """Stop every event's movement."""
2082
+
2083
+
2084
+ # ==========================================================================
2085
+ # Screen
2086
+ # ==========================================================================
2087
+
2088
+
2089
+ def erase_screen(transition: Transition = "default") -> None:
2090
+ """Erase Screen: hide the map with a transition (effects done before
2091
+ show_screen() appear with it)."""
2092
+
2093
+
2094
+ def show_screen(transition: Transition = "default") -> None:
2095
+ """Show Screen after erase_screen()."""
2096
+
2097
+
2098
+ def tint_screen(
2099
+ red: Fixed | None = None,
2100
+ green: Fixed | None = None,
2101
+ blue: Fixed | None = None,
2102
+ saturation: Fixed | None = None,
2103
+ duration: float | None = None,
2104
+ wait: bool | None = None,
2105
+ extra: Extra = (),
2106
+ ) -> None:
2107
+ """Tint Screen: colour 0-200 per channel (100 = normal), over `duration` seconds."""
2108
+
2109
+
2110
+ def flash_screen(
2111
+ red: Fixed | None = None,
2112
+ green: Fixed | None = None,
2113
+ blue: Fixed | None = None,
2114
+ strength: Fixed | None = None,
2115
+ duration: float | None = None,
2116
+ wait: bool | None = None,
2117
+ mode: FlashMode | None = None,
2118
+ extra: Extra = (),
2119
+ ) -> None:
2120
+ """Flash Screen: colour 0-31 per channel; mode begin/end repeats (2003)."""
2121
+
2122
+
2123
+ def shake_screen(
2124
+ strength: Fixed | None = None,
2125
+ speed: Fixed | None = None,
2126
+ duration: float | None = None,
2127
+ wait: bool | None = None,
2128
+ mode: FlashMode | None = None,
2129
+ extra: Extra = (),
2130
+ ) -> None:
2131
+ """Shake Screen (strength and speed 1-9); mode begin/end shakes until stopped (2003)."""
2132
+
2133
+
2134
+ def pan_screen(direction: Direction, distance: Fixed, speed: Fixed = 3, wait: bool = False) -> None:
2135
+ """Scroll the view by `distance` tiles away from the hero."""
2136
+
2137
+
2138
+ def reset_screen_pan(speed: Fixed = 3, wait: bool = False, direction: Direction = "up", distance: Fixed = 0) -> None:
2139
+ """Scroll the view back to the hero."""
2140
+
2141
+
2142
+ def lock_screen(direction: Direction = "up", distance: Fixed = 0, speed: Fixed = 0, wait: bool = False) -> None:
2143
+ """Lock the view: it stops following the hero."""
2144
+
2145
+
2146
+ def unlock_screen(direction: Direction = "up", distance: Fixed = 0, speed: Fixed = 0, wait: bool = False) -> None:
2147
+ """Unlock the view: it follows the hero again."""
2148
+
2149
+
2150
+ def weather(kind: WeatherKind, strength: Strength = "weak") -> None:
2151
+ """Weather effect: rain, snow, fog or sandstorm (2003), or none."""
2152
+
2153
+
2154
+ # ==========================================================================
2155
+ # Audio and video
2156
+ # ==========================================================================
2157
+
2158
+
2159
+ def play_bgm(name: str, fade: Fixed = 0, volume: Fixed = 100, tempo: Fixed = 100, balance: Fixed = 50) -> None:
2160
+ """Play a music of the Music folder (MIDI, WAV, MP3, OGG).
2161
+
2162
+ Args:
2163
+ fade: fade-in in milliseconds.
2164
+ volume: 0-100.
2165
+ tempo: 50-150 (100 = normal speed).
2166
+ balance: 0 (left) - 100 (right), 50 = centre.
2167
+ """
2168
+
2169
+
2170
+ def play_se(name: str, volume: Fixed = 100, tempo: Fixed = 100, balance: Fixed = 50) -> MoveStep:
2171
+ """Play a sound effect of the Sound folder ("(OFF)" stops all sounds).
2172
+ RPG_RT plays at most 4 sounds at once. Also usable as a move step."""
2173
+ return MoveStep()
2174
+
2175
+
2176
+ def fade_out_bgm(seconds: float) -> None:
2177
+ """Fade the music out."""
2178
+
2179
+
2180
+ def memorize_bgm() -> None:
2181
+ """Remember the current music."""
2182
+
2183
+
2184
+ def play_memorized_bgm() -> None:
2185
+ """Play the music remembered with memorize_bgm()."""
2186
+
2187
+
2188
+ def play_movie(
2189
+ name: str,
2190
+ *,
2191
+ x: Number = 0,
2192
+ y: Number = 0,
2193
+ width: Fixed | None = None,
2194
+ height: Fixed | None = None,
2195
+ extra: Extra = (),
2196
+ ) -> None:
2197
+ """Play a movie (.avi) of the Movie folder at a position and size."""
2198
+
2199
+
2200
+ # ==========================================================================
2201
+ # Flow and menus
2202
+ # ==========================================================================
2203
+
2204
+
2205
+ def wait(seconds: float = 0, key: bool = False) -> None:
2206
+ """Wait in steps of 0.1 s. ``wait(0.0)`` still pauses for a moment;
2207
+ ``wait(key=True)`` waits for a key press (2003)."""
2208
+
2209
+
2210
+ def label(id: Fixed) -> None:
2211
+ """A jump target for goto(id); with duplicates only the first counts."""
2212
+
2213
+
2214
+ def goto(id: Fixed) -> None:
2215
+ """Jump to label(id)."""
2216
+
2217
+
2218
+ def break_loop() -> None:
2219
+ """Break Loop outside a while loop (inside one, write ``break``)."""
2220
+
2221
+
2222
+ def game_over() -> None:
2223
+ """Show the game over screen."""
2224
+
2225
+
2226
+ def return_to_title() -> None:
2227
+ """Go back to the title screen."""
2228
+
2229
+
2230
+ def open_save_menu() -> None:
2231
+ """Open the save screen."""
2232
+
2233
+
2234
+ def open_main_menu() -> None:
2235
+ """Open the main menu."""
2236
+
2237
+
2238
+ def open_load_menu(*, extra: Extra = ()) -> None:
2239
+ """Open the load screen (2003)."""
2240
+
2241
+
2242
+ def exit_game(*, extra: Extra = ()) -> None:
2243
+ """Close the game (2003)."""
2244
+
2245
+
2246
+ def toggle_fullscreen(*, extra: Extra = ()) -> None:
2247
+ """Switch between window and fullscreen (2003)."""
2248
+
2249
+
2250
+ def toggle_atb_mode(*, extra: Extra = ()) -> None:
2251
+ """Switch the battle gauge between active and wait modes (2003)."""
2252
+
2253
+
2254
+ def open_video_options(*, extra: Extra = ()) -> None:
2255
+ """Open the video / settings menu (2003; EasyRPG settings menu)."""
2256
+
2257
+
2258
+ # ==========================================================================
2259
+ # Battles, shops, inns
2260
+ # ==========================================================================
2261
+
2262
+
2263
+ def start_battle(
2264
+ troop: Number,
2265
+ *,
2266
+ background: Literal["map", "image", "terrain"] | None = None,
2267
+ escape: Literal["disallow", "end_event", "branch"] | None = None,
2268
+ defeat: Literal["game_over", "branch"] | None = None,
2269
+ first_strike: bool | None = None,
2270
+ condition: Literal["none", "initiative", "back_attack", "surround", "pincer"] | None = None,
2271
+ formation: Literal["terrain", "loose", "tight"] | None = None,
2272
+ terrain: Fixed | None = None,
2273
+ image: str | None = None,
2274
+ extra: Extra = (),
2275
+ ) -> str:
2276
+ """Start a battle. With branches, write it as a match::
2277
+
2278
+ match start_battle(3, escape="branch", defeat="branch"):
2279
+ case "victory": ...
2280
+ case "escape": ...
2281
+ case "defeat": ...
2282
+
2283
+ Args:
2284
+ troop: troop id.
2285
+ background: from the map, an image (``image=``), or a terrain (``terrain=``).
2286
+ escape: forbid escaping, end the event on escape, or an "escape" branch.
2287
+ defeat: game over, or a "defeat" branch.
2288
+ first_strike: the party attacks first.
2289
+ condition, formation: battle start condition and formation (2003).
2290
+ """
2291
+ return ""
2292
+
2293
+
2294
+ def open_shop(
2295
+ items: list[int],
2296
+ *,
2297
+ mode: Literal["buy_sell", "buy", "sell"] | None = None,
2298
+ style: Fixed | None = None,
2299
+ branches: bool | None = None,
2300
+ p3: Fixed | None = None,
2301
+ extra: Extra = (),
2302
+ ) -> str:
2303
+ """Open a shop selling `items`. For branches use
2304
+ ``match open_shop([...]):`` with ``case "bought":`` / ``case "not_bought":``.
2305
+
2306
+ Args:
2307
+ mode: buy and sell, buy only or sell only.
2308
+ style: shop message set (0-2).
2309
+ """
2310
+ return ""
2311
+
2312
+
2313
+ def inn(price: Fixed, *, style: Fixed | None = None, branches: bool | None = None, extra: Extra = ()) -> str:
2314
+ """Offer a night at the inn. For branches use ``match inn(50):`` with
2315
+ ``case "stayed":`` / ``case "declined":``.
2316
+
2317
+ Args:
2318
+ price: price in gold.
2319
+ style: inn message set (0-1).
2320
+ """
2321
+ return ""
2322
+
2323
+
2324
+ def set_battle_background(name: str, *, extra: Extra = ()) -> None:
2325
+ """Change the battle background (in battle)."""
2326
+
2327
+
2328
+ def show_battle_animation(
2329
+ animation: Fixed, target: Fixed, wait: bool | None = None, allies: bool | None = None, *, extra: Extra = ()
2330
+ ) -> None:
2331
+ """Show a battle animation on an enemy (in battle; 2003 can target allies)."""
2332
+
2333
+
2334
+ def end_battle(*, extra: Extra = ()) -> None:
2335
+ """End the current battle."""
2336
+
2337
+
2338
+ def battle_call_common_event(common_event: Fixed, *, extra: Extra = ()) -> None:
2339
+ """Call a common event from a battle (2003)."""
2340
+
2341
+
2342
+ def force_flee(
2343
+ who: Literal["party", "all_enemies", "enemy"],
2344
+ enemy: Fixed | None = None,
2345
+ ignore_conditions: bool | None = None,
2346
+ *,
2347
+ extra: Extra = (),
2348
+ ) -> None:
2349
+ """Make the party or enemies flee (2003)."""
2350
+
2351
+
2352
+ def enable_combo(actor: Fixed, command: Fixed, times: Fixed, *, extra: Extra = ()) -> None:
2353
+ """Let a hero use a battle command several times per turn (2003)."""
2354
+
2355
+
2356
+ # ==========================================================================
2357
+ # Generic command
2358
+ # ==========================================================================
2359
+
2360
+
2361
+ def cmd(
2362
+ code: int | CommandName, *params: int, text: str = "", indent: int | None = None
2363
+ ) -> AbstractContextManager[None]:
2364
+ """Any event command by code or name with its raw parameters, e.g.
2365
+ ``cmd("TintScreen", 100, 100, 100, 100, 20, 1)``. ``with cmd(...):``
2366
+ opens a block for commands that have one. rpgsync uses it only for
2367
+ patch commands (Maniac, EasyRPG) and unusual data."""
2368
+ return nullcontext()
2369
+
2370
+
2371
+ # What `from rpgsync.dsl import *` gives the scripts (tests/test_scaffold.py keeps it
2372
+ # complete). Left out: CommonEvents, which database/common_events.py defines, and
2373
+ # the typing helpers.
2374
+ __all__ = [
2375
+ "Actor",
2376
+ "ActorTarget",
2377
+ "Actors",
2378
+ "AnimationType",
2379
+ "BgmContext",
2380
+ "CancelOption",
2381
+ "Character",
2382
+ "CommandName",
2383
+ "CommonEvent",
2384
+ "CommonEventFunction",
2385
+ "CommonEventTable",
2386
+ "CommonEventTrigger",
2387
+ "Condition",
2388
+ "Counter",
2389
+ "Digits",
2390
+ "Direction",
2391
+ "DynArg",
2392
+ "DynNumber",
2393
+ "DynRPG",
2394
+ "DynString",
2395
+ "DynToken",
2396
+ "Enemies",
2397
+ "Enemy",
2398
+ "EquipSlot",
2399
+ "Event",
2400
+ "Events",
2401
+ "Extra",
2402
+ "FaceIndex",
2403
+ "FlashMode",
2404
+ "Frequency",
2405
+ "GameState",
2406
+ "Item",
2407
+ "Items",
2408
+ "Layer",
2409
+ "ManiacPatch",
2410
+ "ManiacValue",
2411
+ "MessagePosition",
2412
+ "MoveStep",
2413
+ "MoveType",
2414
+ "N",
2415
+ "NV",
2416
+ "NVV",
2417
+ "Number",
2418
+ "Party",
2419
+ "Pattern",
2420
+ "Percent",
2421
+ "Picture",
2422
+ "PictureEffect",
2423
+ "Pictures",
2424
+ "PlayerCharacter",
2425
+ "Route",
2426
+ "SeContext",
2427
+ "SkillMode",
2428
+ "Speed",
2429
+ "SpriteIndex",
2430
+ "Stat",
2431
+ "StatMode",
2432
+ "Strength",
2433
+ "Switch",
2434
+ "SwitchRange",
2435
+ "Switches",
2436
+ "TeleportDirection",
2437
+ "ThisEvent",
2438
+ "Timer",
2439
+ "Transition",
2440
+ "TransitionKind",
2441
+ "Trigger",
2442
+ "TroopEventTable",
2443
+ "V",
2444
+ "VV",
2445
+ "VVV",
2446
+ "Value",
2447
+ "Variable",
2448
+ "VariableRange",
2449
+ "Variables",
2450
+ "Vehicle",
2451
+ "VehicleCharacter",
2452
+ "WeatherKind",
2453
+ "Word",
2454
+ "actors",
2455
+ "add_battle_command",
2456
+ "add_state",
2457
+ "add_teleport_target",
2458
+ "airship",
2459
+ "battle_call_common_event",
2460
+ "battle_condition",
2461
+ "bgm_looped",
2462
+ "boat",
2463
+ "break_loop",
2464
+ "change_class",
2465
+ "change_exp",
2466
+ "change_graphic",
2467
+ "change_hp",
2468
+ "change_level",
2469
+ "change_sp",
2470
+ "change_stat",
2471
+ "cmd",
2472
+ "comment",
2473
+ "common_event",
2474
+ "cond",
2475
+ "dyn",
2476
+ "enable_combo",
2477
+ "end_battle",
2478
+ "enemies",
2479
+ "enter_hero_name",
2480
+ "equip",
2481
+ "erase_screen",
2482
+ "event",
2483
+ "event_id_at",
2484
+ "events",
2485
+ "exit_game",
2486
+ "face",
2487
+ "face_away_from_player",
2488
+ "face_down",
2489
+ "face_left",
2490
+ "face_player",
2491
+ "face_random",
2492
+ "face_right",
2493
+ "face_up",
2494
+ "fade_out_bgm",
2495
+ "fatigue",
2496
+ "flash_screen",
2497
+ "force_flee",
2498
+ "forget_skill",
2499
+ "frequency_down",
2500
+ "frequency_up",
2501
+ "full_heal",
2502
+ "game",
2503
+ "game_over",
2504
+ "goto",
2505
+ "halt_all_movement",
2506
+ "inn",
2507
+ "input_number",
2508
+ "items",
2509
+ "jump_end",
2510
+ "jump_start",
2511
+ "key_input",
2512
+ "label",
2513
+ "learn_skill",
2514
+ "lock_facing",
2515
+ "lock_screen",
2516
+ "maniac",
2517
+ "memorize_bgm",
2518
+ "memorize_location",
2519
+ "message_options",
2520
+ "move",
2521
+ "move_away_from_player",
2522
+ "move_down",
2523
+ "move_down_left",
2524
+ "move_down_right",
2525
+ "move_forward",
2526
+ "move_left",
2527
+ "move_random",
2528
+ "move_right",
2529
+ "move_toward_player",
2530
+ "move_up",
2531
+ "move_up_left",
2532
+ "move_up_right",
2533
+ "n",
2534
+ "nv",
2535
+ "nvv",
2536
+ "open_load_menu",
2537
+ "open_main_menu",
2538
+ "open_save_menu",
2539
+ "open_shop",
2540
+ "open_video_options",
2541
+ "page",
2542
+ "pan_screen",
2543
+ "party",
2544
+ "pause",
2545
+ "percent",
2546
+ "phasing_off",
2547
+ "phasing_on",
2548
+ "pictures",
2549
+ "play_bgm",
2550
+ "play_memorized_bgm",
2551
+ "play_movie",
2552
+ "play_se",
2553
+ "player",
2554
+ "randint",
2555
+ "recall_location",
2556
+ "remove_battle_command",
2557
+ "remove_state",
2558
+ "remove_teleport_target",
2559
+ "replace_tile",
2560
+ "reset_screen_pan",
2561
+ "return_to_title",
2562
+ "route",
2563
+ "set_battle_background",
2564
+ "set_encounter_rate",
2565
+ "set_escape_target",
2566
+ "set_panorama",
2567
+ "set_system_bgm",
2568
+ "set_system_graphics",
2569
+ "set_system_se",
2570
+ "set_tileset",
2571
+ "set_transition",
2572
+ "set_vehicle_location",
2573
+ "shake_screen",
2574
+ "ship",
2575
+ "show_battle_animation",
2576
+ "show_choices",
2577
+ "show_screen",
2578
+ "simulate_attack",
2579
+ "speed_down",
2580
+ "speed_up",
2581
+ "start_animation",
2582
+ "start_battle",
2583
+ "started_by_action_key",
2584
+ "stop_animation",
2585
+ "swap_events",
2586
+ "switch_off",
2587
+ "switch_on",
2588
+ "teleport",
2589
+ "terrain_id",
2590
+ "text",
2591
+ "this",
2592
+ "timer1",
2593
+ "timer2",
2594
+ "tint_screen",
2595
+ "toggle_atb_mode",
2596
+ "toggle_fullscreen",
2597
+ "toggle_vehicle",
2598
+ "transparency_down",
2599
+ "transparency_up",
2600
+ "troop",
2601
+ "turn",
2602
+ "turn_around",
2603
+ "turn_left",
2604
+ "turn_random",
2605
+ "turn_right",
2606
+ "unequip",
2607
+ "unlock_facing",
2608
+ "unlock_screen",
2609
+ "v",
2610
+ "vv",
2611
+ "vvv",
2612
+ "wait",
2613
+ "wait_for_movement",
2614
+ "weather",
2615
+ "word",
2616
+ ]