Registrarse

[Dis - Scripting] Scripts de nivel

Estado
Cerrado para nuevas respuestas.

Felipe

Profesional de WaH
Hola, buenas.
Estoy haciendo script en pokeemerald y quiero hacer un script de nivel (por asi decirlo) pero cada vez que intento algo con una variable o flag sin usar.
al salir al mapa este queda en negro y se cuelga el juego.

alguien sabe como hacerlo correctamente, o algun tutorial de como hacerlo.
 

Jack Johnson

Hoenn Adventures Dev
Miembro del equipo
Administrador
@Felipe ¿Recuerdas nuestros viejos amigos en Advance Map? Cada tipo tenía un número. Aquí esos tipos tienen nombre y son estos:
C:
#ifndef GUARD_CONSTANTS_MAP_SCRIPTS_H
#define GUARD_CONSTANTS_MAP_SCRIPTS_H
/*
    IDs for special scripts that can be run for a particular map.
    For the functions that handle when they are run, see these constants' uses in src/script.c
    Below describes when a script of this kind will be called, and what it typically does.
    They are numbered in the order that they will be called when entering a map (from a warp or camera transition).
    NOTE: These descriptions are just of what they generally do, not what they always or have to do
    3. ON_LOAD: Run after the layout is loaded (but not drawn yet).
                Almost exclusively used to set metatiles on the map before it's first drawn
    6. ON_FRAME_TABLE: Run every frame after the map has faded in, before player input is processed.
                       This is a table of scripts that each run if their condition is satisfied.
                       Used to trigger an event, such as the player exiting the cable car or the SS Tidal sailor announcing progress
    2. ON_TRANSITION: Run during the transition to the map
                      Used to set map-specific flags/vars, update object positions/movement types, set weather, etc
    5. ON_WARP_INTO_MAP_TABLE: Run after the map's objects are loaded.
                               This is a table of scripts that each run if their condition is satisfied.
                               Used to add objects to the scene or update something about the player as they warp in (e.g. their facing dir or visibility)
                               Note that ON_TRANSITION may also handle object visibility, but would do so by modifying a flag or var
    4. ON_RESUME: Run at the end of map load, and again any time upon returning to field (e.g. exiting the Bag menu, or finishing a battle)
                  Used to hide defeated static pokemon, or maintain some map state (e.g. the Trainer Hill timer, or the cycling road challenge)
                  In some maps this takes the metatile setting job of ON_LOAD
    1. ON_DIVE_WARP: Run after the player chooses to dive/emerge.
                     Only used once, to determine whether or not the player should emerge in the Sealed Chamber
    x. ON_RETURN_TO_FIELD: Run exlusively upon returning to the field, shortly after ON_RESUME (as opposed to ON_RESUME, which also runs once on entering the map)
                           Used rarely, when something must only happen on reload (e.g. making sure Mew is above the grass after battling it on Faraway Island)
*/
#define MAP_SCRIPT_ON_LOAD 1
#define MAP_SCRIPT_ON_FRAME_TABLE 2
#define MAP_SCRIPT_ON_TRANSITION 3
#define MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE 4
#define MAP_SCRIPT_ON_RESUME 5
#define MAP_SCRIPT_ON_DIVE_WARP 6
#define MAP_SCRIPT_ON_RETURN_TO_FIELD 7
#endif // GUARD_CONSTANTS_MAP_SCRIPTS_H
Primero comprueba que estás usando el script de tipo correcto. Si eso no se aplica a tu caso, este sería el prototipo por así decirlo de los scripts de nivel con variable:
Ruby:
NombreMapa_MapScripts::
    map_script MAP_SCRIPT_ON_FRAME_TABLE, NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE
    .byte 0

NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE:
    map_script_2 VAR_ELEGIDA, 0, NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE_0
    map_script_2 VAR_ELEGIDA, 1, NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE_1
    .2byte 0

NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE_0:
    lock
    msgbox NombreMapa_Texto_1
    closemessage
    setvar VAR_ELEGIDA, 1
    release
    end

NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE_1:
    lock
    msgbox NombreMapa_Texto_2
    closemessage
    setvar VAR_ELEGIDA, 2
    release
    end

NombreMapa_Texto_1::
    .string "La variable vale 0.$"

NombreMapa_Texto_2::
    .string "Ahora la variable vale 1.$"
Ruby:
mapscripts NombreMapa_MapScripts {
    MAP_SCRIPT_ON_FRAME_TABLE [
            VAR_ELEGIDA, 0
            {
                lock
                msgbox(NombreMapa_Texto_1)
                closemessage
                setvar(VAR_ELEGIDA, 1)
                release
                end
            },
            VAR_ELEGIDA, 1
            {
                lock
                msgbox(NombreMapa_Texto_2)
                closemessage
                setvar(VAR_ELEGIDA, 2)
                release
                end
            }
    ]
}

text NombreMapa_Texto_1 {
    format("La variable vale 0.")
}

text NombreMapa_Texto_2 {
    format("Ahora la variable vale 1.")
}
En la sección NombreMapa_MapScripts se crea una tabla de scripts de nivel, indicando con la palabra clave map_script cada uno. A continuación, va el tipo del script de nivel y, finalmente, el nombre del script. La tabla se finalizará con .byte 0.

Hay que tener en cuenta que en scripts de tipo MAP_SCRIPT_ON_FRAME_TABLE y MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE lo que se hace es crear otra tabla de scripts, como se ha hecho en NombreMapa_MapScripts_MAP_SCRIPT_ON_FRAME_TABLE. En este caso, se vuelve a colocar la palabra clave, ahora map_script_2. A continuación, se coloca el nombre de la variable elegida, el valor en el cual se activará el script y, por último, el nombre del script. La tabla se finalizará con .2byte 0.

Ya solo queda que hagas tu script como siempre, teniendo en cuenta que debe tener el mismo nombre que has puesto en la tabla.
 
Estado
Cerrado para nuevas respuestas.
Arriba