Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2016-11-10 14:23:09

henkiebobo
Member
Registered: 2016-07-14
Post 11/13

fighting a legendary event..

Okay, so for my personal hack I'm using pokecrystal and I want to create a fight somewhere (not sure where yet) with the legendary dogs at a low level (level 20). The idea is probably that I'd put them in a house or on a route close to ecruteak, you see the sprite, you talk to it and you fight them.

Now I figure I could just copy ho-oh or lugia's data and paste it in another map, but I don't really understand all the data that I'm seeing. Like the last line where it says .personevents and it lists a whole bunch of variables. What do they represent? I see one is the sprite, but there's also one that says: SPRITEMOVEDATA_POKEMON. What is that?

I am still quite a newb at assembly so some guidance would be greatly appreciated..

Offline

#2 2016-11-10 18:55:24

Rangi
Member
Registered: 2016-05-09
Post 304/554

Re: fighting a legendary event..

Here's the code of maps/WhirlIslandLugiaChamber.asm with added comments.

;; Each sprite on the map--trainers, Berry trees, Strength boulders, legendary
;; Pokémon, etc--needs a constant to identify it in scripts. The "const_value
;; set 2" is always the same no matter how many sprites you list.
const_value set 2
;; Lugia is the only sprite on the map. "MAPNAME_SPRITENAME" is the usual
;; pattern used to avoid duplicate names.
    const WHIRLISLANDLUGIACHAMBER_LUGIA

;; With that out of the way, you can start defining map scripts.
WhirlIslandLugiaChamber_MapScriptHeader:
;; "Map triggers" are used to automatically run a script under certain
;; circumstances, like as soon as you enter a map, or when you step on a
;; certain tile.
.MapTriggers:
;; This map doesn't have any triggers, so you say the count is 0 and don't list
;; any.
    db 0

;; "Map callbacks" also run automatically under certain circumstances, before
;; the triggers do.
.MapCallbacks:
;; This map has one callback.
    db 1

    ; callbacks

;; Here you specify the type of callback, and the script it should run.
;; The types are listed in constants/map_setup_constants.asm: TILES, OBJECTS,
;; CMDQUEUE, SPRITES, and NEWMAP. The names refer to when the callback is
;; run, like, as soon as the map is created, or before sprites are displayed.
;; If you try to do certain things at the wrong time, the game could freeze
;; or crash. Just refer to other maps' callbacks for which types are appropriate
;; for which things.
    dbw MAPCALLBACK_OBJECTS, .Lugia

;; Here's the callback definition.
.Lugia:
    ;; This logic amounts to "If EVENT_FOUGHT_LUGIA is not set and the player
    ;; has the SILVER_WING item, then show Lugia, otherwise do not". Events are
    ;; unset by default, unless they were set by the InitializeEventsScript
    ;; script in engine/std_scripts.asm.
    checkevent EVENT_FOUGHT_LUGIA
    iftrue .NoAppear
    checkitem SILVER_WING
    iftrue .Appear
    jump .NoAppear

.Appear:
    appear WHIRLISLANDLUGIACHAMBER_LUGIA
    return

.NoAppear:
    disappear WHIRLISLANDLUGIACHAMBER_LUGIA
    return

;; This script is the one assigned to Lugia's sprite down below in PersonEvents,
;; so it runs when you press A to talk to Lugia. It's a list of commands that
;; run one at a time, until the "end" command. A full list of commands is the
;; ScriptCommandTable in engine/scripting.asm. Some names are self-explanatory,
;; others are more obscure.
Lugia:
    faceplayer
    opentext
    writetext LugiaText
    cry LUGIA
    pause 15
    closetext
    ;; Remember the callback earlier that hid Lugia if this event was set? It
    ;; gets set now, before the battle starts, so whether you win or lose
    ;; Lugia will be gone.
    setevent EVENT_FOUGHT_LUGIA
    ;; Battle types are listed in constants/battle_constants.asm. If you don't
    ;; specify one, you'll get BATTLETYPE_NORMAL, a normal battle. You can
    ;; search through the code for where BATTLETYPE_FORCEITEM is used to see
    ;; what effects it has. As the name hints, it forces Lugia to hold the item
    ;; defined in data/base_stats/lugia.asm--although that item is NO_ITEM, so
    ;; this is a bit silly. It's more useful for the Vermilion City Snorlax,
    ;; who is defined to hold Leftovers.
    writecode VAR_BATTLETYPE, BATTLETYPE_FORCEITEM
    ;; Level 60 Lugia.
    loadwildmon LUGIA, 60
    startbattle
    disappear WHIRLISLANDLUGIACHAMBER_LUGIA
    reloadmapafterbattle
    end

;; "text" begins a block of text shown by the writetext command. "line" starts
;; a new line; each line can fit 18 characters. "para" clears the two-line text
;; box and restarts at the top. "cont" is used if you printed two lines already;
;; it scrolls down to write another. "done" ends the text, of course.
LugiaText:
    text "Gyaaas!"
    done

;; Now the "map scripts" are over, and "map events" are defined. Map events are
;; warps, xy triggers, signposts, and person events. Each type is explained
;; more below.
WhirlIslandLugiaChamber_MapEventHeader:
    ; filler
    db 0, 0

;; Warps teleport/warp you to a different map when you step on them. The tile
;; you step on has to have a warpable collision type for it to work. If you're
;; making your own maps, make sure to set warps on top of doors, ladders, holes,
;; etc. If you're making your own tilesets, make sure to use a warpable
;; collision ID. I listed all of them at https://hax.iimarck.us/post/42130/.
.Warps:
    ;; There's one warp.
    db 1
    ;; The parameters are: y, x, id, map. y and x locate the warp on the map;
    ;; y is "number of tiles down" and x is "number of tiles right" from the
    ;; top-left corner. You don't have to use hexadecimal numbers, but the
    ;; pokecrystal maps consistently do so. Just don't mix them up; $10 is 16,
    ;; not 10. (I know hexadecimal, but have still made this mistake before.)
    ;; The warp id corresponds to the map: look at the warps defined in
    ;; WhirlIslandB2F.asm, you'll see that the third one is to Lugia's chamber.
    ;; You don't have to make warps in pairs, but of course that makes sense
    ;; for back-and-forth doors.
    warp_def $d, $9, 3, WHIRL_ISLAND_B2F

;; XY triggers run an event when you step on a certain tile, if the "map
;; trigger" is correct. Each map has a map trigger that starts at 0. For
;; example, New Bark Town has XY triggers defined for map trigger 0 that
;; stop you from leaving (the NPC tells you it's dangerous). Then when you
;; get your starter it runs the command "domaptrigger NEW_BARK_TOWN, $1",
;; which sets the map trigger to 1 for New Bark Town, so the XY trigger for 0
;; doesn't run and you can leave.
.XYTriggers:
    ;; There are no triggers on this map.
    db 0

;; Signposts are events that run when you talk to a certain tile that doesn't
;; have a person on it. (If a person wanders on top of a signpost, you'll talk
;; to the person, not the signpost.) Signpost events are used for literal
;; signposts, and also for hidden items.
.Signposts:
    db 0

;; Person events are NPCs. People, Pokémon, boulders, Berry trees, Poké Balls.
.PersonEvents:
    ;; There's one on this map.
    db 1
    ;; Lots of parameters here: sprite ID, y, x, movement type, y movement
    ;; radius, x movement radius, "clock_hour", "clock_daytime", color, person
    ;; type, sight range, script, and event flag. (The parameters have brief
    ;; comments in macros/map.asm naming them.)
    ;; * The sprite is selected from constants/sprite_constants.asm.
    ;; * The y and x coordinates place it on the map, just like warps.
    ;; * The movement type is selected from constants/sprite_constants.asm.
    ;;   It defines how the sprite moves. SPRITEMOVEDATA_POKEMON makes it
    ;;   wiggle in place like the Pokémon in your party menu.
    ;; * The y and x movement radii apply to wandering sprites (like those with
    ;;   SPRITEMOVEDATA_WANDER or SPRITEMOVEDATA_WALK_UP_DOWN), and constrain
    ;;   how far they can walk from their starting location.
    ;; * I've never used the "clock_hour" parameter; it's always -1.
    ;; * The "clock_daytime" parameter can be (1 << MORN), (1 << DAY), or
    ;;   (1 << NITE) to make a sprite only appear at that time; or -1 for all
    ;;   times. It's used in KrissHouse1F.asm and MountMoonGiftShop.asm.
    ;; * The color is selected from constants/sprite_constants.asm. You have to
    ;;   include the "(1 << 3) |" part, and then whatever PAL_OW color you
    ;;   want.
    ;; * The person type is selected from constants/map_constants.asm. It can be
    ;;   a SCRIPT, ITEMBALL, or TRAINER. SCRIPT runs when you talk to it,
    ;;   ITEMBALL has a simple map script definition that automatically runs a
    ;;   standard larger script defined elsewhere, and trainers have their
    ;;   complex behavior of noticing you and auto-battling.
    ;; * The sight radius applies to trainers: how many tiles ahead they can
    ;;   notice you and walk towards you to battle.
    ;; * The event script is, of course, the one you defined earlier.
    ;; * The event flag determines whether the sprite is visible. If this
    ;;   event is off (the default), the sprite is visible; if it's on, the
    ;;   sprite is gone. The "appear" and "disappear" commands toggle this
    ;;   event. Notice that it's not the same as the EVENT_FOUGHT_LUGIA flag:
    ;;   in general you want to have separate flags just for sprite visibility,
    ;;   so that it's independent of any other conditions.
    person_event SPRITE_LUGIA, 5, 9, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, Lugia, EVENT_WHIRL_ISLAND_LUGIA_CHAMBER_LUGIA

(Edited to explain the "clock_daytime" person_event parameter.)

Last edited by Rangi (2016-11-17 01:07:01)


ROM hack: Pokémon Polished Crystal — version 2.2.0 released!

Offline

#3 2016-11-11 08:39:29

henkiebobo
Member
Registered: 2016-07-14
Post 12/13

Re: fighting a legendary event..

That is very thorough, I can definitely work with that! Thanks a bunch! In a way, it opened up alot more opportunities so I hope I don't get lost in the possibilities hehe :P.

Thanks though!

Offline

Board footer

Powered by FluxBB