Advertiser Content

Tutorial [XSE] Scripting Tutorial Page 3

Started by Avara July 14th, 2017 2:24 PM
  • 18151 views
  • 63 replies

Avara

Female
Izantine
Seen 2 Days Ago
Posted 2 Days Ago
1,085 posts
7.9 Years
Trigger Scripts

What's a trigger script, you might be wondering? By a "trigger script", I mean those little green "S" tiles visible in AdvanceMap's Events tab. When your player steps on these, the script it contains will run. I'll show you how to set these up step by step!

First of all, you'll have to choose a variable to use. For example purposes, we'll be using var 0x4050. I'll draw your attention to the "Var value" box, outlined in red below:


Currently, the value is set to 0. This means that the script will only run while var 4050 has a value of 0. Let's say we want the script to run only once:
#dynamic 0x800000

#org @main
lock
msgbox @msg 0x6
setvar 0x4050 0x1
release
end

#org @msg
= This is a trigger.
In this script, we've set var 0x4050's value to 1. Since the variable's value is no longer 0, the script will not run again.

If you want your trigger script to repeat itself until the variable is set somewhere else in another script, you can do this too. Maybe you want it to act as a roadblock until your player has completed a certain event.
#dynamic 0x800000

#org @main
lock
msgbox @msg 0x6
applymovement 0xff @stepdown
waitmovement 0x0
setvar 0x4050 0x0
release
end

#org @msg
= This is a trigger.

#org @stepdown
#raw 0x08
#raw 0xfe
Since this time we're keeping the variable as 0, that means this script will run every time the player steps on the "S" tile until the variable has a new value other than 0.

Avara

Female
Izantine
Seen 2 Days Ago
Posted 2 Days Ago
1,085 posts
7.9 Years
Screen Colour Filters

FireRed has a nice little quirk that allows you to change the screen's colours to sepia tones or black and white after a warp.
If you're hacking Emerald you won't be able to use these.

For a black & white filter, you'd use the following.
writebytetooffset 0x1 0x2036E28
[Type Of Warp] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0
A fuller demonstration script:
'---------------
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @msg 0x4
closeonkeypress
writebytetooffset 0x1 0x2036E28
warpmuted 0x3 0x1 0x0 0x0 0x0
release
end

#org @msg
= Applying black and white filter.

For a sepia filter, you'd use this.
writebytetooffset 0x2 0x2036E28
[Type Of Warp] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0
And again, a more detailed example:
'---------------
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @msg 0x4
closeonkeypress
writebytetooffset 0x2 0x2036E28
warpmuted 0x3 0x1 0x0 0x0 0x0
release
end

#org @msg
= Applying sepia filter.

To go back to normal, just substitute the value following writebytetooffset to 0x0:
writebytetooffset 0x0 0x2036E28
[Type Of Warp] 0x[Map Bank] 0x[Map Number] 0x[Warp Number] 0x0 0x0

Avara

Female
Izantine
Seen 2 Days Ago
Posted 2 Days Ago
1,085 posts
7.9 Years
Fadescreen Effects

Just when it seems as if I'm getting closer to being finished with this tutorial, I think of something else I should have added!
It's easy to give the overworld a "fading out" effect - useful for cutscenes and such - by using the fadescreen command which looks like this:
fadescreen 0x[Fade Type Number]
What do I mean by "fade type number"? Here are the numbers for fading out to black and then reverting to normal:
fadescreen 0x1 – Screen fades to black.
fadescreen 0x0 - Screen fades from black back to normal.
Time for an example script and gif so you can see how it looks in-game!
'---------------
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @msg 0x6
fadescreen 0x1
fadescreen 0x0
release
end

#org @msg
= Screen fading to black.

It's also possible to create a white version of the same effect by swapping out the 0x1 and 0x0 for 0x3 and 0x2 respectively.
'---------------
#dynamic 0x800000

#org @start
lock
faceplayer
msgbox @msg 0x6
fadescreen 0x3
fadescreen 0x2
release
end

#org @msg
= Screen fading to white.

To serve as a reminder, here is a list of all the fadescreen types for quick reference:
0x3 – Screen fades to white.
0x2 – Screen fades from white back to normal.

0x1 – Screen fades to black.
0x0 - Screen fades from black back to normal.
Seen September 6th, 2019
Posted April 23rd, 2019
1 posts
297 Days
I Am trying to make a command to work after i am talking to an other sprite (person), for exaple:

I want 0x1200 to say a msg @talk1 0x6
Then when i talk to an other person 0x1201,
Then 0x1200 @talk1 0x6 stops and @talk2 0x5 starts, then stops and @talk3 0x6 starts, then @talk3 stop and @talk1 0x6 starts.
When i talk to an other sprite (person) 0x1202,
Then 0x1200 @talk1 0x6 stops and @talk2 0x5 starts, then stops and
@talk4 0x6 starts, then @talk4 0x6 stop and @talk1 0x6 starts.
Then 0x1200 When i talk to an other sprite (person) 0x1203,
@talk1 0x6 stop and @talk2 0x5 starts, then stops and
@talk5 0x6 starts, then @talk4 0x6 stop and @talk1 0x6
starts.

Can someone helps me please?
Seen 3 Weeks Ago
Posted 3 Weeks Ago
3 posts
42 Days
Hello, this is a great tutorial but I am having an issues I was hoping you could help with. The problem is that I have having an NPC ignore my "lock" command in a longer script. The script is for him to give me a Pokemon, then a notification appears and a fanfare plays, then I can nickname the Pokemon, and finally he tells me to take good care of his Pokemon. But when the notification appears, the NPC is released from the "lock" and starts walking around. So, when he tells me to take good care of his Pokemon, he isn't standing by me anymore, which is weird. How can I get him to stay locked until the script is totally complete? Here is my code:
#dynamic 0x800000
#org @givepokemon
lock
faceplayer
checkflag 0x100
if 0x0 goto @give
msgbox @2 0x2
end

#org @give
msgbox @1 0x6
givepokemon 0x7B 0x5 0x44 0x0 0x0 0x0
fanfare 0x13E             //Plays the player received pokemon fanfare
msgbox @notify 0x4
setflag 0x828
waitfanfare
closeonkeypress 
setflag 0x100
msgbox @qname 0x5         //Asks the player if they want to nickname their pokemon
compare LASTRESULT 0x1    //Checks to see if the player selected 'Yes'
if 0x1 gosub @nickname    //If yes then the @nickname script will run and then return
msgbox @3 0x6
release
end

#org @nickname
countpokemon              // Stores 0x1 in LASTRESULT since we only have one pokemon now
subvar LASTRESULT 0x1     // Subtracts 0x1 from the value stored in LASTRESULT, so LASTRESULT is now 0x0
copyvar 0x8004 LASTRESULT // Copies LASTRESULT into 0x8004. Both are now 0x0
fadescreen 0x1
special 0x9E              // 0x8004 is needed for special 0x9E
waitstate
return

#org @1
= Please take care of my Scyther\nfor me.

#org @2
= How is my Scyther doing [player]?

#org @notify
= [Player] received SCYTHER!

#org @qname
= Would you like to give SCYTHER a\nnickname?

#org @3
= Take good care of my Scyther!
Seen 3 Weeks Ago
Posted 3 Weeks Ago
4 posts
35 Days
Hi there, I'm having trouble with XSE. When I write a script then go to compile it the scripts I'm writing are changing.
for example here's what I scripted.
Spoiler:
'---------------
#org 0x800A00
lock
faceplayer
msgbox 0x8800A85 MSG_FACE '"Huh oh hi my name's BELL\poh you h..."
removeitem 0x15D 0x1
msgbox 0x8800AF6 MSG_FACE '"Thank you\pOh, I know have this I ..."
giveitem 0x6D 0x1 MSG_OBTAIN
msgbox 0x8800B76 MSG_FACE '"Well I should be off now, bye!"
applymovement MOVE_PLAYER 0x8800C6C
waitmovement 0x0
applymovement 0x3 0x8800C70
waitmovement 0x0
hidesprite 0x3
setflag 0x39
showsprite 0x4
clearflag 0x32
applymovement 0x4 0x8800FB5
waitmovement 0x0
applymovement MOVE_PLAYER 0x880107A
waitmovement 0x0
msgbox 0x8800D61 MSG_FACE '"Hello there, that Item your\nholdi..."
trainerbattle 0x3 0x8 0x0 0x8800EFC
msgbox 0x8800F1E MSG_FACE '"Well now\pI guess I'll take my lea..."
applymovement 0x4 0x8800FC6
waitmovement 0x0
setflag 0x35
release
end

But when I compile the script and open it again it comes out like this
Spoiler:
'---------------
#org 0x800A00
lock
faceplayer
msgbox 0x8800A85 MSG_FACE '"Huh oh hi my name's BELL\poh you h..."
removeitem 0x15D 0x1
msgbox 0x8800AF6 MSG_FACE '"Thank you\pOh, I know have this I ..."
giveitem 0x6D 0x1 MSG_OBTAIN
msgbox 0x8800B76 MSG_FACE '"Well I should be off now, bye!"
applymovement MOVE_PLAYER 0x8800C6C
waitmovement 0x0
applymovement 0x3 0x8800C70
waitmovement 0x0
hidesprite 0x3
setflag 0x39
showsprite 0x4
clearflag 0x32
applymovement 0x4 0x8800FB5
waitmovement 0x0
applymovement MOVE_PLAYER 0x880107A
waitmovement 0x0
msgbox 0x8800D61 MSG_FACE '"Hello there, that Item your\nholdi..."
trainerbattle 0x3 0x8 0x0 0x8800EFC
msgbox 0x8800F1E MSG_FACE '"Well now\pI guess I'll take my lea..."
applymovement 0x4 0x8800FC6
waitmovement 0x0
setflag 0xC235

I've "highlighted" the changes so it's easier to see.
Please help

Burtle

Discord: Burtle#6904

Seen 2 Weeks Ago
Posted 3 Weeks Ago
29 posts
35 Days
Please help
Try
#org 0x800A00
lock
faceplayer
msgbox 0x8800A85 MSG_FACE '"Huh oh hi my name's BELL\poh you h..."
removeitem 0x15D 0x1
msgbox 0x8800AF6 MSG_FACE '"Thank you\pOh, I know have this I ..."
giveitem 0x6D 0x1 MSG_OBTAIN
msgbox 0x8800B76 MSG_FACE '"Well I should be off now, bye!"
applymovement MOVE_PLAYER 0x8800C6C
waitmovement 0x0
applymovement 0x3 0x8800C70
waitmovement 0x0
hidesprite 0x3
setflag 0x39
showsprite 0x4
clearflag 0x32
applymovement 0x4 0x8800FB5
waitmovement 0x0
applymovement MOVE_PLAYER 0x880107A
waitmovement 0x0
msgbox 0x8800D61 MSG_FACE '"Hello there, that Item your\nholdi..."
trainerbattle 0x3 0x8 0x0 0x8800EFC
msgbox 0x8800F1E MSG_FACE '"Well now\pI guess I'll take my lea..."
applymovement 0x4 0x8800FC6
waitmovement 0x0
setflag 0x35
goto @end

#org @end
releaseall
end
?
Advertiser Content