FMF:Plotscript Status

From OHRRPGCE-Wiki
(Redirected from FMF:Plotdict)
Jump to navigation Jump to search
Mobile-phone.png
This article is about the OHRRPGCE FMF project, which is an alternate implementation of the OHRRPGCE for Java mobile phones. Technical implementation details discussed here should not be confused with those of the RPG format


This page will detail the current implementation status of Plotscripting in the OHRRPGCE FMF project. It is intended to help you answer questions like "Why doesn't the camera scroll?" and so forth.

Note that these details apply to the latest fortnightly, not the latest stable release.


Color Index[edit]

Color Status in the OHRRPGCE FMF
Fully Implemented
Partly Implemented
Buggy
Not Applicable


Trigger Implementation Status[edit]

Script Name Arguments+
New-Game Script
Game-Over Script
Load-Game Script slot_loaded:[0..4,-1]
Text Box Scripts
Item Scripts (via previous)
NPC Scripts X:[?]
npc_ref
Vehicle Scripts
   Mount
   Dismount
   Use
   Cancel
Inn Script
Map OnEnter Script X:[?]
After-Battle Script won:[true,false]
Instead-of-Battle Script formation_num
formation_set_num
Each-Step Script hero_x
hero_y
facing_dir
On-Keypress Script

+Note: You may want to review the full description of these script triggers. Also, very briefly, arguments that have a :[STH] after them are bounded by that STH. So, won:[true, false] means that "won" can have a value of true or false. X:[?] is just a special notation to describe user-administered parameters.

Language Implementation Status[edit]

Primitives[edit]

Primitive Description
small numbers Integers less than (add later)
large numbers Integers larger than (add later)
unbounded numbers Integers of any size
/{string} define {...} define a function
strings Strings encoded in ASCII
unicode strings Strings encoded in UTF-16


API-Level Primitives[edit]

ID Command Description Henceforth Name
0 noop no operation noop


Wait Commands[edit]

ID Command Description Henceforth Name
1 wait wait(cycles) wait
2 waitforall wait for script-related walking&panning to stop
3 waitforhero wait for hero to stop moving
4 waitfornpc wait for npc to stop moving wait_npc
9 waitforkey wait for a keypress
42 waitforcamera waits for pan or focus to finish wait_cam
59 waitfortextbox waits for text box to go away wait_txt


Suspend/Resume Commands[edit]

ID Command Description Henceforth Name
5 suspendnpcs pause normal NPC movement
6 suspendplayer stop the player from controlling stuff (except text boxes) sus_play
27 suspendoverlay turns off overhead tiles
65 resumeoverlay turns overhead tiles back on
7 resumenpcs resume npc automation
8 resumeplayer unlock players controls rsm_play
47 suspendobstruction lets heros walk through NPCs and vice versa sus_block
48 resumeobstruction restores normal obstruction behavior rsm_block
49 suspendherowalls lets heros walk through walls
50 suspendNPCwalls lets heros and npcs walk through walls
95 resumeNPCwalls restores normal NPC wall behavior
51 resumeherowalls restores normal hero wall behavior
84 suspendboxadvance prevents user from advancing text boxes
85 resumeboxadvance reverses suspendboxadvance
168 suspendrandomenemies keeps random enemies from attacking
169 resumerandomenemies undoes suspendrandomenemies
118 suspendcaterpillar other heros stop following the leader, and can be manipulated separately.
119 resumecaterpillar turns catapillar party back on
57 suspendcatapillar misspelled alias for backcompat*
58 resumecatapillar misspelled alias for backcompat*
62 suspendrandomenemys misspelled alias for backcompat*
63 resumerandomenemys misspelled alias for backcompat*

*Note: Since misspelled tags are only required at compile time, space need not be reserved for them in the FMF's interpreter.


Camera Commands[edit]

ID Command Description Henceforth Name
38 camerafollowshero make camera follow a hero cam_hero
39 camerafollowsnpc make camera follow an npc
40 pancamera pan camera(direction,distance,pixelstep) pan_cam
41 focuscamera focus camera(x,y,pixelstep)
137 putcamera (x,y) set screen pixel position
142 camerapixelx ? get camera pixel x
143 camerapixely ? get camera pixel y


System Commands[edit]

ID Command Description Henceforth Name
74 setdeathscript changes what script is run when you die
77 showvalue display a number in the bottom left corner
79 shownovalue hide the number from showvalue
30 keyval check key by scancode - returns value from keyval array
12 checktag returns the value of a tag
13 settag set tag(#,true/false)
103 resetpalette return the master palette to defaults
104 tweakpalette alter the master palette
105 readcolor return a color value
106 writecolor change a color value
107 updatepalette apply changes made with writecolor
108 seedrandom ? reseed the random number generator
109 greyscalepalette convert the palette to greyscale
114 readglobal index
115 writeglobal index,value
144 loadtileset load a new tileset for the current map
147 readgeneral directly read from the in-memory array of general game data
148 writegeneral directly write to the in-memory array of general game data. If you crash your game with this command, don't be too surprised
159 initmouse init mouse, return true if a mouse is installed
160 mousepixelx returns mouse x coordinate on the screen
161 mousepixely returns mouse y coordinate on the screen
162 mousebutton returns true if the specified button is pressed
163 putmouse places the mouse at a point on the screen
164 mouseregion define the rectangle in which the mouse can move (xmin, xmax, ymin, ymax)
170 savemenu display the save menu
171 saveslotused returns true if a saved game exists in the specified slot
172 importglobals (slot, first, last) reads a range of globals from a save slot
173 exportglobals (slot, first, last) writes a range of globals to a save slot
174 loadfromslot loads saved game from slot
175 deletesave delete (hide from load/save screen - data not *actaully* deleted) specified slot
176 runscriptbyid run a script by its id number and pass up to 8 arguments
166 saveinslot save game in slot
167 lastsaveslot returns the last save slot the game was saved in, false if unsaved
187 getmusicvolume music volume on a scale of 0-255 regardless of implementation
188 setmusicvolume set music volume on a scale of 0-255
189 getformationsong returns the song associated with a given formation
190 setformationsong sets the song associated with a given formation
200 system hour
201 system minute
202 system second
203 current song
209 get global string (string, global) - puts the global string (global) in string(string)
210 showstring shows string on the bottom(stringID)
211 clearstring deletes the data from string(stringID)
212 appendascii adds ascii to string(stringID,ascii)
213 appendnumber adds number to string(stringID,number)
214 copystring copies string from one to another(sourceID,destinationID)
215 concatenatestrings adds two strings(sourceID,destinationID)
216 stringlength returns the length of string(stringID)
217 deletechar deletes character from string(stringID,position)
218 replacechar replaces character in the specified string(stringID,position,ascii)
219 asciifromstring returns the ascii in the string(ascii number)(stringID,position)
220 positionstring move a string to a position on the screen(stringID,x,y)
221 setstringbit set a string bit, such as: visibility, style(stringID,bit,value)
222 getstringbit return a string bit, such as: visibility, style(stringID,bit)
223 stringcolor set a string's color,also optional background color(stringID,fColor,bColor)
224 stringx return a string's X position(stringID)
225 stringy return a string's Y position(stringID)
226 systemday returns system day
227 systemmonth returns system month
228 systemyear returns system year
229 stringcompare returns whether two strings are the same(stringID1, stringID2)
230 readenemydata reads enemy data(enemy,dataposition)
231 writeenemydata writes enemy data(enemy,dataposition,value)
232 trace writes the provided string to G_DEBUG.txt
233 getsongname get song name and store in string
197 playsound plays an sfx (num, loop?, preempt?)
198 pausesound pauses an sfx (num) (stop, but don't rewind)
199 stopsound stops an sfx (num) (stop, and rewind)
235 keyispressed check key by scancode, returns a bool

Game Engine Commands[edit]

ID Command Description Henceforth Name
15 usedoor use door(#)
11 showtextbox show a text box show_txt
16 fightformation fight formation(#)
34 dismountvehicle dismount whatever vehicle you may be riding
37 useshop ? use shop(#)
61 teleporttomap teleport to map (map,x,y)
28 playsong play song(#)
29 stopsong stop the music
32 showbackdrop showbackdrop (#)
33 showmap cancels a showbackdrop
73 gameover returns you to the title screen
75 fadescreenout fade screen out (red,green,blue)
76 fadescreenin fade back to color after fade screen out
80 currentmap returns the number of the current map
86 advancetextbox as if the user had pressed a key
97 readmapblock get mapblock x,y
98 writemapblock set mapblock x,y,value
99 readpassblock get passblock x,y
100 writepassblock set passblock x,y,value
151 showminimap display the mini-map
153 itemsmenu display the items menu
157 ordermenu display the order menu
158 teammenu display the team menu
178 readgmap read from general map data array
179 writegmap write a gmap data item
180 mapwidth returns map height in tiles
181 mapheight returns map width in tiles
17 getitem get item(item,quantity)
18 deleteitem delete item(item,quantity)
20 getmoney get money(amount)
21 losemoney ? lose money(amount) no checking
22 paymoney returns false and subtracts nothing if cannot afford
82 inventory returns the count of a given item
129 readspell (who,list,slot) returns the number of the spell in a slot
130 writespell (who,list,slot,spell) forces a hero to learn a spell
206 get item name (string, item) - puts the name of item(item) in string(string)
207 get map name (string, map) - puts the name of map(map) in string(string)
208 get attack name (string, attack) - puts the name of attack(attack) in string(string)

NPC Manipulation Commands[edit]

ID Command Description Henceforth Name
120 NPCreference get an NPC reference by ID number
121 NPCatspot get NPC reference by X,Y
122 getNPCID get the ID number of an NPC reference
123 NPCcopycount find out how many copys of an NPC ID are on the map
124 changeNPCID given an NPC reference, changes its ID
125 createNPC create an NPC by ID at a location and return its reference
126 destroyNPC destroy the referenced NPC
35 useNPC trigger an NPC remotely
192 npcframe (who)
26 setNPCframe (who,frame) frame is 0 or 1
45 npcx returns the npc's x coordinate
46 npcy returns the npc's y coordinate
88 setNPCposition arbitraraly set x,y
136 putnpc (who,x,y) set npc pixel position
140 npcpixelx (who) get npc pixel x
141 npcpixely (who) get npc pixel y
165 npcatpixel returns NPC at pixel x,y, third arg is which npc (on -1 returns number of npcs at pixel)
54 setnpcdirection set npc direction(who,direction)
101 NPCdirection, return an NPC's direction
52 walknpc walk npc(who,direction,distance) walk_npc
78 alterNPC replaces one of an NPC's stats
177 NPCiswalking (who) returns true if walking (for real)
182 readNPC reads information about an NPC on the current map (corresponds to alterNPC)
193 npcextra get npc extra data (ref, 1 or 2)
194 setnpcextra set npc extra data (ref, 1 or 2,what)

Hero Manipulation Commands[edit]

ID Command Description
10 walkhero walk hero(who,direction,distance)
191 heroframe (who)
25 setheroframe (who,frame) frame is 0 or 1
55 getdefaultweapon (who)
56 setdefaultweapon (who,item)
23 unequip (who,where)
24 forceequip (who,where,item)
60 equipwhere ? (who,item) returns the slot that an item can be equipped in, or false if the hero cant equip it
19 leader returns the current leader
31 rankincaterpillar finds the heros position in the caterpillar
43 herox returns the hero's x coordinate
44 heroy returns the hero's y coordinate
53 setherodirection set hero direction(who,direction)
64 getherostat returns a hero's stat (who,stat,cur/max)
66 addhero adds a hero to the party
67 deletehero deletes a hero from the party
68 swapouthero move a hero out of the active party
69 swapinhero moves a hero into the active party (if there is room)
70 roominactiveparty returns the number of empty slots in the active party (0-3)
71 lockhero prevents swapping of a hero
72 unlockhero ? reverses lockhero
81 setherospeed changes a heros walking speed
83 setherostat alters a hero's stats (who,stat,value,cur/max)
87 setheroposition arbitraraly set x,y
89 swapbyposition swap two hero slots
90 findhero locate hero slot by hero name
91 checkequipment what is a hero equipped with? (who,where)
96 setheroz sets the hero's vertical position
102 herodirection return a hero's direction
110 setheropicture who,picture,type
111 setheropalette who,palette,type
112 getheropicture who,type
113 getheropalette who,type
116 heroiswalking (who)
127 teachspell (who,spell,learntype) tries to teach a hero a spell
128 forgetspell (who,spell) forget a learned spell
131 knowsspell (who,spell) returns true if the hero already knows this spell
132 canlearnspell (who,spell,learntype) returns true if the hero can learn the spell
133 herobyslot returns the hero ID/name of the hero at a particular slot in the party
134 herobyrank returns the hero ID/name of the hero at a particular rank in the caterpillar
135 puthero ? (who,x,y) set hero pixel-position
138 heropixelx ? (who) get hero pixel x
139 heropixely ? (who) get hero pixel y
145 pickhero lets you manually pick a hero
146 renameherobyslot lets you manually rename a hero
150 statusscreen display the status screen for a hero
152 spellsmenu display the spell menu for a hero
154 equipmenu display the equip menu for a hero
183 setherolevel change a hero's level
184 giveexperience (who, how much) gives a hero or the active party experience
185 herolevelled number of levels gained last battle/giveexperience command.
186 spellslearnt number spells and spell ids hero learnt at last battle/giveexperience command.
204 get hero name (string, hero) - puts the name of hero(hero) in string(string)
205 set hero name (string, hero) - sets the name of hero(hero) to string(string)

Obsolete Opcodes[edit]

ID Command
92 daysofplay
93 hoursofplay
94 minutesofplay
117 NPCiswalking
155 savemenu
234 loadmenu #not supported
195 loadsound
196 freesound

*Note: These opcodes can't be re-used (old games might expect them) but they probably should not be re-assigned. This is important for the XRPG conversion tool, but nothing else.


WIP/New Plotscripts I have to add[edit]

236,soundisplaying,1,0 #checks to see if a sound is playing (soundID) #237,soundslots,0 #returns the number of slots available 238,searchstring,3,0,0,1 #Search string, (ID1,ID2,start) 239,trimstring,3,0,-1,1 #Trims the specified string, (ID, start,length) 240,stringfromtextbox,4,0,0,0,0 #loads string with whatever line in whatever textbox you specify 241,expandstring,1,0 #expand ${Hxx}, etc in a string(ID) 242,joystickbutton,2,0,0 #returns whether a given button is pressed (button, joystick) 243,joystickaxis,3,0,100,0 #returns the axis position (axis,multiplier,joystick) 244,waitforscancode,1,0 #waits for a specific scancode 245,savemapstate,2,255,255 #save map data to a temp file (savebits, customid) 246,loadmapstate,2,255,255 #load map data from a temp file (loadbits, customid) 247,resetmapstate,1,255 #reload original map data (loadbits) 248,deletemapstate,1,255 #delete temp map state files (deletebits) 249,partymoney,0 #retrieves amount of gold 250,setmoney,1,0 #sets amount of gold 251,setstringfromtable,2,0,0 #string support function 252,appendstringfromtable,2,0,0 #string support function 253,settileanimationoffset,3,0,0,0 #set offset from starting tile (animation pattern 0/1, offset, layer) 254,gettileanimationoffset,2,0,0 #get offset from starting tile (animation pattern 0/1, layer) 255,animationstarttile,2,0,0 #tile number which this tile starts its animation pattern off as (id of a tile, layer) 256,suspendmapmusic,0 #prevent ambient music from playing on entering a map 257,resumemapmusic,0 #reverse above 258,checkherowall,2,0,0 #check passability in a direction relative to a hero 259,checknpcwall,2,0,0 #check passability in a direction relative to an NPC 260,settimer,6,0,-1,-1,-1,-1,-1#start (or modify) a timer(id, count, speed, trigger, string, flags) 261,stoptimer,1,0 #convenience for settimer(id,-1,0) 262,readtimer,1,0 #returns the count of a timer(id) 263,getcolor,1,0 #returns a 32-bit color from the master palette(index) 264,setcolor,2,0,0 #writes a 32-bit color to the master palette(index,val) 265,rgb,3,0,0,0 #mixes red, green and blue into a 32-bit color(r, g, b) 266,extractcolor,2,0,0 #extracts an RGB component from a 32-bit color(color, component) 267,mainmenu,0 #opens the main menu 268,loadpalette,1,0 #load master palette 269,totalexperience,1,0 #experience gained by a hero 270,experiencetolevel,1,0 #total experience to reach a level 271,experiencetonextlevel,1,0 #experience to level up 272,setexperience,3,0,0,1 #set total experience (who,amount,allow spell forgetting) 273,milliseconds,0 #uptime in milliseconds 274,openmenu,2,0,0 #openmenu(menuID) 275,readmenuint,2,0,0 #read menu int(menuhandle,intid) 276,writemenuint,3,0,0,0 #write menu int(menuhandle,intid,n) 277,readmenuitemint,2,0,0 #read menu item int(menuitemhandle,intid) 278,writemenuitemint,3,0,0,0 #write menu item int(menuitemhandle,intid,n) 279,createmenu,0 #create a blank menu 280,closemenu,1,0 #close menu(handle) 281,topmenu,0 #return a handle to the topmost menu 282,bringmenuforward,1,0 #bring menu forward(menu handle) 283,addmenuitem,1,0 #add menu item(menuhandle) appends, returns menuitemhandle 284,deletemenuitem,1,0 #delete menu item(menuitemhandle) 285,getmenuitemcaption,2,0,0 #get menu item caption(menuitemhandle, string ID) 286,setmenuitemcaption,2,0,0 #set menu item caption(menuitemhandle, string ID) 287,getlevelmp,2,0,0 #get level mp(hero party slot, mp level) 288,setlevelmp,3,0,0,0 #set level mp(hero party slot, mp level, new value) 289,bottommenu,0 #return a handle to the bottommost menu 290,previousmenu,1,0 #given a menu handle, return a handle to the menu beneath it 291,nextmenu,1,0 #given a menu handle, return a handle to the menu on top of it 292,menuitembyslot,3,0,0,true #menu item by slot(menu handle, slotnum, visible only) returns menuitemhandle 293,previousmenuitem,2,0,true #given a menuitemhandle return handle to the menu item before it 294,nextmenuitem,2,0,true #given a menuitemhandle return handle to the menu item after it 295,selectedmenuitem,1,0 #selected menu item(menu handle) returns menuitemhandle 296,selectmenuitem,1,0 #select menu item(menu item handle) moves the cursor 297,parentmenu,1,0 #parent menu(menu item handle) returns menu handle 298,getmenuid,1,0 #menu ID(menu handle) returns the ID of the menu 299,swapmenuitems,2,0,0 #swap menu items(handle1, handle2) 300,findmenuitemcaption,4,0,0,0,1 #find menu item caption(menu handle, string ID, search after handle=false, visible only=true) 301,findmenuid,1,0 #find menu(menu ID) search open menus for menu ID and return menu handle 302,menuisopen,1,0 #menu is open(menu handle) # return true as long as the handle is still valid 303,menuitemslot,1,0 #menu item slot(menu item handle) returns a menu slot number 304,outsidebattlecure,3,0,0,-1 #out of battle cure(attack ID, target, attacker) 305,changetileset,2,-1,-1 #similar to loadtileset. (tileset,layer) 306,layertileset,1,0 #layer tileset(layer) returns tileset number in use 307,getformationsong,1,0 #returns the song associated with a given formation 308,addenemytoformation,5,0,0,85,95,-1 #add enemy to formation(formation, enemy id, x, y, slot = -1) returns slot or -1 309,findenemyinformation,3,0,0,0 #find enemy in formation(formation, enemy id, number) returns slot or -1 310,deleteenemyfromformation,2,0,0 #delete enemy from formation(formation, slot) 311,formationslotenemy,2,0,0 #formation slot enemy (formation, slot) returns enemy in slot 312,formationslotx,2,0,0 #formation slot x(formation, slot) returns x of enemy in slot 313,formationsloty,2,0,0 #formation slot y(formation, slot) returns y of enemy in slot 314,setformationbackground,4,0,0,1,0 #set formation background(formation, background, animation frames, animation ticks) 315,getformationbackground,1,0 #get formation background(formation) returns background number 316,lastformation,0 #last formation fought 317,randomformation,1,0 #pick a formation from a formation set 318,formationsetfrequency,1,0 #returns (as percentage) set frequency 319,formationprobability,2,0,0 #returns (as percentage) formation being picked from formation set probability 320,currenttextbox,0 #currently displayed textbox or -1 321,getherospeed,1,0 #hero walk speed (hero) 322,load hero sprite,2,0,-1 #load hero sprite (number, palette) 323,free sprite, 1, 0 #frees a sprite (id) 324,place sprite, 3, 0, 0, 0 #move a sprite(id, x, y) 325,set sprite visible,2,0,0 #change sprite visibilty(id, vis) 326,set sprite palette,2,0,0 #set sprite palette(id, pal) 327,replaceherosprite,3,0,0,-1 #replaces the sprite with a hero sprite (id, num, pal) 328,setspriteframe,2,0,0 #what it says on the tin(id, num) 329,loadwalkaboutsprite,2,0,-1 #load walkabout sprite (number, palette) 330,replacewalkaboutsprite,3,0,0,-1 #replaces the sprite with a walkabout sprite (id, num, pal) 331,loadweaponsprite,2,0,-1 #load weapon sprite (number, palette) 332,replaceweaponsprite,3,0,0,-1 #replaces the sprite with a weapon sprite (id, num, pal) 333,loadsmallenemysprite,3,0,0,-1 #load enemy sprite (number, palette) 334,replacesmallenemysprite,4,0,0,0,-1 #replaces the sprite with an enemy sprite (id, num, pal) 335,loadmediumenemysprite,3,0,0,-1 #load enemy sprite (number, palette) 336,replacemediumenemysprite,4,0,0,0,-1 #replaces the sprite with an enemy sprite (id, num, pal) 337,loadlargeenemysprite,3,0,0,-1 #load enemy sprite (number, palette) 338,replacelargeenemysprite,4,0,0,0,-1 #replaces the sprite with an enemy sprite (id, num, pal) 339,loadattacksprite,2,0,-1 #load attack sprite (number, palette) 340,replaceattacksprite,3,0,0,-1 #replaces the sprite with an attack sprite (id, num, pal) 341,loadbordersprite,2,0,-1 #load a textbox border (number, palette) 342,replacebordersprite,3,0,0,-1 #replaces the sprite with a textbox border (id, num, pal) 343,loadportraitsprite,2,0,-1 #load a character portrait (number, palette) 344,replaceportraitsprite,3,0,0,-1 #replaces the sprite with a character portrait (id, num, pal) 345,clonesprite,2,0, 0 #returns a copy of the given sprite(ID, pal)