Difference between revisions of "Common functions"

From Unofficial QEdit Wiki Guide
Jump to: navigation, search
(Created page with "This page holds many functions that should serve as a helpful reference. Keep in mind that these snipets are meant to be guides, and show some level of standard, but may not...")
 
Line 1: Line 1:
This page holds many functions that should serve as a helpful reference.
+
This page holds many functions that should serve as a helpful reference. Some functions hold specific numbers because they are so broadly used and treated as if they are reserved they will be labeled as "Function #: Name". It's a best to write any custom functions with a label of 152+. Common function examples that do not have a specific number tied to them will be labeled as "Custom Function #: Name" and placed after the regular functions.
  
 
Keep in mind that these snipets are meant to be guides, and show some level of standard, but may not always be suitable for direct reuse.
 
Keep in mind that these snipets are meant to be guides, and show some level of standard, but may not always be suitable for direct reuse.
Line 29: Line 29:
 
'''GC:'''
 
'''GC:'''
  
<code>
+
<nowiki>
 
0:      set_episode 00000000
 
0:      set_episode 00000000
 
         set_floor_handler 00000000, 150
 
         set_floor_handler 00000000, 150
Line 38: Line 38:
 
         leti R64, 00000000
 
         leti R64, 00000000
 
         map_designate_ex R60
 
         map_designate_ex R60
         ret  
+
         ret</nowiki>
</code>
+
  
 
'''BB:'''
 
'''BB:'''
Line 47: Line 46:
 
You'll see frequently that this is used in scripts to quickly terminate switches
 
You'll see frequently that this is used in scripts to quickly terminate switches
  
<code>
+
<nowiki>
1:      ret  
+
1:      ret</nowiki>
</code>
+
  
 
==Function 2: Start Cinematic==
 
==Function 2: Start Cinematic==
 
This function essentially disables the character, hides hud, and zooms in with cinematic bars
 
This function essentially disables the character, hides hud, and zooms in with cinematic bars
  
<code>
+
<nowiki>
 
2:      p_action_disable  
 
2:      p_action_disable  
 
         npc_nont
 
         npc_nont
Line 61: Line 59:
 
         cine_enable  
 
         cine_enable  
 
         cam_zmin  
 
         cam_zmin  
         ret  
+
         ret</nowiki>
</code>
+
  
 
==Function 3: End Cinematic==
 
==Function 3: End Cinematic==
 
This undoes the changes that 2 does, but in reverse order. This should help avoid errors, and let the player play again.
 
This undoes the changes that 2 does, but in reverse order. This should help avoid errors, and let the player play again.
  
<code>
+
<nowiki>
 
3:      cam_zmout  
 
3:      cam_zmout  
 
         cine_disable  
 
         cine_disable  
Line 74: Line 71:
 
         npc_talk
 
         npc_talk
 
         p_action_enable  
 
         p_action_enable  
         ret  
+
         ret</nowiki>
</code>
+
  
 
==Function 150: First Map==
 
==Function 150: First Map==
Line 82: Line 78:
 
If we follow the example from function 0, you will note this is called every time you load into Pioneer 2, so we only jump to 151 if the quest is not yet started, otherwise do nothing by jumping to 1.
 
If we follow the example from function 0, you will note this is called every time you load into Pioneer 2, so we only jump to 151 if the quest is not yet started, otherwise do nothing by jumping to 1.
  
<code>
+
<nowiki>
150:    switch_jmp R0, 2:151:1
+
150:    switch_jmp R0, 2:151:1</nowiki>
</code>
+
  
 
==Function 151: First Map Initialize==
 
==Function 151: First Map Initialize==
Line 91: Line 86:
 
Often what is added here is teleporting the player, a call to 2, Quest Giver NPC Intro speech, a call to 3, then setting R0 (sometimes this is done before talking, or during talking), then the music.
 
Often what is added here is teleporting the player, a call to 2, Quest Giver NPC Intro speech, a call to 3, then setting R0 (sometimes this is done before talking, or during talking), then the music.
  
<code>
+
<nowiki>
 
151:    set R0
 
151:    set R0
 
         bgm 00000001
 
         bgm 00000001
         ret
+
         ret</nowiki>
</code>
+

Revision as of 17:29, 8 May 2019

This page holds many functions that should serve as a helpful reference. Some functions hold specific numbers because they are so broadly used and treated as if they are reserved they will be labeled as "Function #: Name". It's a best to write any custom functions with a label of 152+. Common function examples that do not have a specific number tied to them will be labeled as "Custom Function #: Name" and placed after the regular functions.

Keep in mind that these snipets are meant to be guides, and show some level of standard, but may not always be suitable for direct reuse.

As you learn to use QEdit you will find that any of these may need changes, additions, or that some functions will have strange quirks.

Please update any function with the appropriate notes for the betterment of the community, and please keep these in numerical order.

You'll also notice some commonly used registers used here. For more information see [common_registers]

Function Intro

It is highly recommended that you take the time to understand the following before using this page

  • How setting registers works
  • How calling vs. jumping works
  • What the reserved registers are

Function 0: Main

The following code is the bare minimum 0 required to start a quest.

This only sets the variables needed to load into pioneer2 in this example, then calls 150 to set the quest to started.

Whatever you do, just be sure that in your chain of functions that 0 sets off, that R0 gets set (done here in 150 -> 151).

V2:

V1:

GC:

0:      set_episode 00000000
        set_floor_handler 00000000, 150
        leti R60, 00000000
        leti R61, 00000000
        leti R62, 00000000
        leti R63, 00000000
        leti R64, 00000000
        map_designate_ex R60
        ret

BB:

Function 1: Ret

This function is commonly used to be a "do nothing" sort of script. You'll see frequently that this is used in scripts to quickly terminate switches

1:      ret

Function 2: Start Cinematic

This function essentially disables the character, hides hud, and zooms in with cinematic bars

2:      p_action_disable 
        npc_nont
        disable_movement2 R250
        hud_hide 
        cine_enable 
        cam_zmin 
        ret

Function 3: End Cinematic

This undoes the changes that 2 does, but in reverse order. This should help avoid errors, and let the player play again.

3:      cam_zmout 
        cine_disable 
        hud_show 
        enable_movement2 R250
        npc_talk
        p_action_enable 
        ret

Function 150: First Map

Here we see a common use of function 1.

If we follow the example from function 0, you will note this is called every time you load into Pioneer 2, so we only jump to 151 if the quest is not yet started, otherwise do nothing by jumping to 1.

150:    switch_jmp R0, 2:151:1

Function 151: First Map Initialize

Technically speaking the only thing required here is to set R0, but to be slightly more illustrative I've put here to play the jingle in here.

Often what is added here is teleporting the player, a call to 2, Quest Giver NPC Intro speech, a call to 3, then setting R0 (sometimes this is done before talking, or during talking), then the music.

151:    set R0
        bgm 00000001
        ret