1.) No point in re-inventing the wheel. Use functions!
But don't only copy then paste them like the name implies, take a moment
to read why they work, and learn something. That way, you can add/subtract
to the script to change it according to what you want.
2.) I'd highly reccomend making all gifs you use for your npc's
have dimensions divisible by 16. That of course, is to make the onwall
detection, or hit detection very easy. As I pointed out in section
2G.
3.) Debunking the explosions. Explosions... difficult
to say what I want to say about explosions. I really like to mess
around with them, so this tip is quite extensive =) They are usually
put using the "putexplosion" (with the new "putexplosion2" command, "putexplosion"
shouldn't be used any more.) command, in which you specify a radius, x,
and y for it. Most people don't know this, but the radius can be
any whole number. Including 0, and negative numbers. Each time
you add 1 to the radius (when using values greater than 0), a new "explo"
is put, with a size of 32x32 pixels. Lets take a look at an explosion,
with a radius of 1.
Here you see the explosion
on a grid. Each square is 16x16 pixels (for the same reasons as pointed
out in section 2G). At the very center of the blast,
that is taking up 4 squares, and, since 1 square is the equivalent of 1
tile, the center is taking up 2x2 tiles. Above, below, to the left,
and right of that center piece, you see more fire that takes up 2x2 spaces.
Each piece of the explosion that is 2x2 tiles adds 1 to the variable in
section
12, "exploscount". So, if this is the only
explosion on the level, exploscount=5 (5 parts taking up 2x2 tiles).
Continuing with the explosion variables, there are explos[index].x, and
explos[index].y. The top left corner of each piece of the explosion
is read as the explosion's x,y. So imagine that going left to right,
the tiles are numbered 1,2,3,4,5,6 and going top to bottom, they are 1,2,3,4,5,6.
So the x,y of the center piece will be 3,3. The piece to the left
will be 0,3. To the right its 5,3. Up will be 3,0. And
bottom will be 3,5. This is all important to know when you want to
use the removeexplo command. It will only remove the explosion piece
of the specified index. Keep in mind this will not remove the ENTIRE
thing (that's why throughout my whole rant, I refer to the different parts
as pieces). Another, more difficult variable, is explos[index].dir.
When I first read it, I had no clue as to what that was supposed to be
used for. But, here's what it means: The top explosion piece will
be read as having a dir of 0 (since 0=up). Left of course is 1, etc
etc. The direction is determined by where it is comming from when
compared to the center of the blast. I'm still learning a bit about
this, so I have no clue as to what the dir of the center piece is.
Any information would be apercited.
Lets take a look at what happens when you make the radius 2.
I'm not going to go
over this as extensivly as I did above, but with this as the only explosion
on the level, exploscount will be 9. The center, 2 going up, 2 down,
2 left, and 2 right.
Remember I said you can use 0, and negative numbers for putexplosion?
Well vars get really messed up when you use 0. This is what it'll
look like:
All the different pieces
of the explosion are on the same space, and because of this all the directions
are messed up as well.
These problems are not aparent when using negative numbers. Lets
look at -1.
In this case, the dirs
get flipped around (the right side has a dir of 1 which is left, and so
on). Keep in mind this is a radius of -1, and an exploscount of 5.
The coolt hing about negative explosions though, can be seen when we
up the radius to -2.
Well, as you can see,
exploscount is still 5. The difference is, the different pieces of
the explosion are now separated from the center. So with negative
values for the radius, the end pieces only get further away from the center,
instead of making the actual explosion larger. This makes negative
radii hard to use effectivly, but they look cool!
4.) Always make sure you spell your variables and flags correctly.
When you hit the "test" button, Graal will still read the vars and flags
and won't give you an error, even though you misspelled something.
Here's a good way to make sure everything is spelt right: push "F6"
to open the editor. Look in the "this.vars" list as well as
the "vars" list. If you see a variable you made appearing
more than once (but spelt slightly different) or it appears in the "this.var"
window as well as the "var" window, then you need to make that one
variable either "this." or not.
5.) Know when to use if, while, and for.
For and While loops cycle through at an exteremly fast rate, and can be
useful for those reasons.
6.) Sleep is a good command, but keep in mind that nothing else
can happen to the NPC while it is sleeping.
7.) Know how to read/manipulate indexes. With the new
vars added to 1.3.6, NPCs can do A LOT more, if you know how to read indexes.