Common functions

From Unofficial QEdit Wiki Guide
Revision as of 17:20, 8 May 2019 by LunarFuror (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 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