PDA

View Full Version : [Tutorial] Some little advanced scripts [Updated 02.14]

liuyanghejerry
February 7th, 2009, 8:43 PM

Though there are some great script tutorial,some advanced script skills are still unknown to some people.Now I'd like to share some of mine with you.
These scripts require that you have already mastered basic script knowledge.

Since 0m3GA ARS3NAL has explain the taken part well,I'm just going to say the retaken part which give back your Pokemon to party
And besides,I don't know ASM,so I can't research the pay script and can only make this free retaken script.

Script first:

special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6

In fact,this is a basic part.Remove anything will destroey the retaken function.
Sorry,I haven' gotten through what these special2s exacly do.But for now,we don't have to know this.Our point is how to make this work well in our hacks.
So,let's make it "fat".

special2 LASTRESULT 0x83

This a good command to check how many Pokemons in your party and store the quantity to LASTRESULT.
So we use it like this:

special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full

Now we have made our check function,and let's plant it into our basic retaken part:

#org @start
lock
faceplayer
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full 'jump to the part to tell player that party is full
special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6
release
end

Now we can ensure wheather your party is full,but what if you didn' save any Pokemons?The result is nothing will happen,but it's not perfect for a hack.

special2 LASTRESULT 0xB6

This special2 will get what day-care state you are and save the number to LASTRESULT.
This is a list of numbers and states:

0x1 - Egg is out(this part is at the end of this tutorial )
0x2 - You have just saved only one Pokemon
0x3 - You have saved two Pokemons
Hehe,do you know how to use "special2 LASTRESULT 0xB6" now?
An example:

#org @start
lock
faceplayer
special2 LASTRESULT 0xB6
compare LASTRESULT 0x1
if 0x1 goto @egg
compare LASTRESULT 0x2
if 0x1 goto @onlyone
compare LASTRESULT 0x3
if 0x1 goto @two
goto @save'you haven't save any pokemons yet
#org @egg
message @1 NORMAL
release
end
#org @onlyone
message @2 YESNO
compare LASTRESULT 0x1
if 0x1 goto @save
message @3 YESNO
compare LASTRESULT 0x1
message @4 NORMAL
release
end
#org @save
'This part is the part that 0m3GA ARS3NAL wrote about,so I skip it
#org @two
message @5 YESNO
compare LASTRESULT 0x1
message @4 NORMAL
release
end
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full
special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6
message @4 NORMAL
release
end
#org @1
= You will get an egg!
#org @2
= You can save TWO Pokemons here,\ndo you want to save another one?
#org @3
= Do you want to take back \nyour Pokemons?
#org @4
= See you later.
#org @if_full
message @5 NORMAL
release
end
#org @5
= Your party is full now!

Phew...little big ,isn't it?
Our script is going to complete,but why don't we add some interesting thing?

sound 0x58
checksound
cry LASTRESULT 0x0

These will make the "give back" with a sound~
So,let's see our finil fat script:

#org @start
lock
faceplayer
special2 LASTRESULT 0xB6
compare LASTRESULT 0x1
if 0x1 goto @egg
compare LASTRESULT 0x2
if 0x1 goto @onlyone
compare LASTRESULT 0x3
if 0x1 goto @two
goto @save'you haven't save any pokemons yet
#org @egg
message @1 0x2
release
end
#org @onlyone
message @2 0x5
compare LASTRESULT 0x1
if 0x1 goto @save
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
#org @save'This part is the part that 0m3GA ARS3NAL wrote about,so I skip it
release
end
#org @two
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full
sound 0x58
checksound
cry LASTRESULT 0x0
special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6
message @4 0x2
release
end
#org @if_full
message @5 0x2
release
end
#org @1
= You will get an egg!
#org @2
= You can save TWO Pokemons here,\ndo you want to save another one?
#org @3
= Do you want to take back \nyour Pokemons?
#org @4
= See you later.

#org @5
= Your party is full now!

I heve droped some commands which I think it's useless from the original day-care script,so if there's anything wrong please let me know,thanks.

2.Button Script[FR/LG]
http://www.pokecommunity.com/attachment.php?attachmentid=44960&stc=1&d=1234067905
Have you ever noticed these interesting buttons?If you walk on them,they will make some change in the map.Fun,huh?
Actully,these interesting button working only relying this command:setmaptile.
Setmaptile is a simple command that has explained by some tutorials,but how to use it now?

Most tutorial didn't explain it well,but if research it yourself,you'll find out the truth.
When we want to create a button script,we should set a green "S" script icon in the AM.In this green "S",we must set the "Unknown" value to 0003 and set the Var value to 0063.As for the var,it depends on you,just a free one is ok.

That is to say:

http://www.pokecommunity.com/attachment.php?attachmentid=44959&stc=1&d=1234066590

Having known this,we can make a simple script to test our thought:

#org @start
lockall
compare 0x5000 0x64
if 0x1 goto @has_happened
setmaptile 0xC 0xE 0x2D1 0x0'this should be yours
setmaptile 0xC 0xF 0x2E1 0x0'this should be yours
special 0x8E
setvar 0x5000 0x64
releaseall
end
#org @has_happened
releaseall
end

"lockall" and "releaseall" are the developed version of "lock" and "release".They ensure that nobody can move when script works.
There is a "new" way of command "compare".You must have seen "compare LASTRESULT 0x1",and this is the same way.All what I do is replace the LASTRESULT with another variable.
In this script,when 0x5000 is 0x63,the "setmaptile" cammand will work.
If you want a free variable,just check the new guide.chm which included in the XSE zip.
Now it's clear ,isn't it?
To make it perfect,let's add a effect:

#org @start
lockall
compare 0x5000 0x64
if 0x1 goto @has_happened
special 0x136'earthquake
setmaptile 0xC 0xE 0x2D1 0x0'this should be yours
setmaptile 0xC 0xF 0x2E1 0x0'this should be yours
special 0x8E
setvar 0x5000 0x64
releaseall
end

#org @has_happened
releaseall
end

Well,you may noticed that when you leave this map,what script has done will be cancelled.How can we keep this change?
Now we need some "level script".
If you have read Cooley's tutorial,it's easy for you.
Let's see this script:

@org @start
compare 0x5000 0x64
if 0x1 goto @keep
end
#org @keep
setmaptile 0xC 0xE 0x2D1 0x0'this should be the one you used before
setmaptile 0xC 0xF 0x2E1 0x0'this should be the one you used before
special 0x8E
end

I don't think there are anything need to explain.
So just complie it and get our offset~
Now open your AM ,go to the map and turn to the "head" page.
Add a script and select "setmaptile" and put the offset that we just got.
Save the change in AM.
Hehe,now our work is done~

When the Spcial2 LASTRESULT 0xB6 returns 0x1,it means you hava an egg.But what should we do next?

clearflag 0x266
special 0xB7

This is the basic script of reciving an egg.
The clearflag will tell the system,the egg has been given and the spcial 0xB7 will give the egg to the player.
But we should check if your party is full.

special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x5 goto @full

Just like what I said before,special2 LASTRESULT 0x83 will do it well.
And of course,you can add more subs in this script,such as "Do you like eggs?" before this give egg function.
Now,let's see how to insert our give egg function in to our retaken script.

#org @start
lock
faceplayer
special2 LASTRESULT 0xB6
compare LASTRESULT 0x1
if 0x1 goto @egg
compare LASTRESULT 0x2
if 0x1 goto @onlyone
compare LASTRESULT 0x3
if 0x1 goto @two
goto @save'you haven't save any pokemons yet
#org @egg
message @1 0x5
compare LASTRESULT 0x1
if 0x0 goto @noegg
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x5 goto @if_full
clearflag 0x266
special 0xB7
message @6 0x2
release
end
#org @onlyone
message @2 0x5
compare LASTRESULT 0x1
if 0x1 goto @save
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
#org @save'This part is the part that 0m3GA ARS3NAL wrote about,so I skip it
release
end
#org @two
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full
sound 0x58
checksound
cry LASTRESULT 0x0
special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6
message @4 0x2
release
end
#org @if_full
message @5 0x2
release
end

#org @noegg
message @7 0x2
release
end
#org @1
#org @2
= You can save TWO Pokemons here,\ndo you want to save another one?
#org @3
= Do you want to take back \nyour Pokemons?
#org @4
= See you later.
#org @5
= Your party is full now!
#org @6
#org @7
= Oh,egg is cute,isn't it?

4.Make Scripts Work
For not being understood,what I talk in fact is this kind of scripts:
http://www.pokecommunity.com/attachment.php?attachmentid=44978&stc=1&d=1234154742

Maybe you have the experience that though you had already write a good script in a green "S" icon,the script wouldn't work.
Yes, that's what I faced days ago...
In fact all what we should do is:
(1) Set a free var in AM,such as 5000
(2) Set a number in Var value,such as 0000(I can't test all values,so I prefer to put 0000)
(3) Set the Unknown value to 0003(Seems must be)

Just like what I did in the picture above

#org @1
lockall
compare 5000 0x1' 5000 is what you set before,but 0x1 is a number other than what you set(0x0 in my example)
if 0x1 goto @2 'If this script has happened
message @3 0x2'This what you want your script do ,message is just an example
setvar 5000 0x1' This keeps your script not working again
releaseall
end

#org @2
releaseall
end

#org @3
= See,it works!

5.DAY-CARE script in R/S [load part]
Maybe because FR/LG is based on R/S,the DAY-CARE script is almost the same.
But there is one thing different :

sound 0x5F

attention,sound 0x58 should be changed to sound 0x5F!

Our full script for R/S:

#org @start
lock
faceplayer
special2 LASTRESULT 0xB6
compare LASTRESULT 0x1
if 0x1 goto @egg
compare LASTRESULT 0x2
if 0x1 goto @onlyone
compare LASTRESULT 0x3
if 0x1 goto @two
goto @save'you haven't save any pokemons yet
#org @egg
message @1 0x2
release
end
#org @onlyone
message @2 0x5
compare LASTRESULT 0x1
if 0x1 goto @save
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
#org @save'This part is the part that 0m3GA ARS3NAL wrote about,so I skip it
release
end
#org @two
message @3 0x5
compare LASTRESULT 0x1
message @4 0x2
release
end
special2 LASTRESULT 0x83
compare LASTRESULT 0x6
if 0x1 goto @if_full
sound 0x5F
checksound
cry LASTRESULT 0x0
special2 LASTRESULT 0xB6
setvar 0x8004 0x0
special2 LASTRESULT 0xC0
special 0xC6
message @4 0x2
release
end
#org @if_full
message @5 0x2
release
end
#org @1
= You will get an egg!
#org @2
= You can save TWO Pokemons here,\ndo you want to save another one?
#org @3
= Do you want to take back \nyour Pokemons?
#org @4
= See you later.

#org @5
= Your party is full now!
As you can see,when the var's value is other than what you set in AM,script won't work;If the var's value is what you set in AM, script will work.
That's it ,easy~
All these things for R/S is coming...
Anyway, sorry for my really bad English and this semi-finished product, I'll make it better as soon as possible.

Tropical Sunlight
February 8th, 2009, 3:40 AM
I like the button-setmaptile explanation. Setamptile is the only script I can make :)

liuyanghejerry
February 8th, 2009, 8:56 PM
Update a little~
Yes,I'd say my English is really poor,so if there's anything you couldn't recognise ,just tell me .
And if there's anything wrong,please let me know,because I don't mean to mislead people.

By the way,these are for FR/LG, and the scripts for R/S are coming soon~

Tropical Sunlight
February 9th, 2009, 5:46 AM
I can't believe no-one will post here!
There are some grammatical errors, but it's OK.

liuyanghejerry
February 13th, 2009, 9:35 PM
XD maybe what I said in tutorial is already common sense...
And I'd love to correct my grammatical errors ,if you can point it out...