//Convert functions are used when you want to use the same
vars
in multiple functions. They arent necessary, it just makes //your
script look a little cleaner. So later when you see the GetDist,
HitCheck, and TileCheck scripts, they all use the vars //"this.testx"
and
"this.testy", just call a Convert function before it, and theyll all be
sure to check the correct x,y locations.
function ConvertP(){
this.testx=x;
this.testy=y;
}
//End of Script
Define
x = "x" is the x cord you want to "test".
y = "y" is the y cord you want to "test".
SR: 2Eii
//GetDist is used to get the distance from two different
points.
function GetDist(){
this.distx=abs(this.testx-x);
this.disty=abs(this.testy-y);
this.dist=((this.distx*this.distx)+(this.disty*this.disty))^.5;
}
//End of Script
Define
If you call Convert before this function, you dont need to define
this.testx
or this.testy; otherwise they are the x,y cords you want to get the
distance
from.
x = The x cord you want to get the distance to.
y = The y cord you want to get the distance to.
SR: 2Eii, 10
//Hit Check function. This is used to hit compus, npcs,
and players at (this.testx,this.testy)
function HitCheck(){
c=testcompu(this.testx,this.testy);
if (c>=0)hitcompu c,this.pow,this.testx,this.testy;
p=testplayer(this.testx,this.testy);
if
(p>=0&&players[p].hurtdx==0&&players[p].hurtdy==0)hitplayer
p,this.pow,this.testx,this.testy;
n=testnpc(this.testx,this.testy);
if
(n>=0&&npcs[n].hurtdx==0&&npcs[n].hurtdy==0)callnpc
n,washit;
}
//End of Script
Define
If you call a Convert before this function, then you don't need to
define this.testx, this.testy; otherwise:
this.testx = This is the x cordinate to check if something is to be
hit at; most commonly, this would be the x cordinate of
an
image shown by a weapon.
this.testy = This is the y cordinate to check if something is to be
hit at; most commonly, this would be the y cordinate of
an
image shown by a weapon.
this.pow = The number of half hearts to be taken off when it hits
something.
SR: 2Biii, 2Biii.1,
2C, 2E, 2G,
2Gii, 5, 10,
12
// Tile Checking is used when you want to see if the
specified
(x,y) cordinate on the level is a certain tile.
function TileCheck(){
putx=int(this.testx);
puty=int(this.testy);
b = board[putx+64*puty];
bx = b % 16;
by = int(b / 16);
if (bx==tilex && by==tiley){
command(s);
}
}
//End of Script
Define
If you call a convert function before this, then you dont need to
define
this.testx, this.testy; otherwise:
this.testx = The x cordinate on the level you want to check.
this.testy = The y cordinate on the level you want to check.
tilex = The x value of the tile you want to check for. These
can be found by placing your cursor over the tile.
tiley = The y value of the tile you want to check for. These
can be found by placing your cursor over the tile.
SR: 2Bi, 2Bii,
2E, 2Ei,
2Eii, 2G,
2Gi, 10, 12
// Aiming is a little difficlut to explain, and probably
less
useful than my other functions. It was used in the smart baddy
//(available
in the downloads section). This function needs to always be
called
within a timeout loop. Basically, it moves the //NPC along the x
OR y axis toward the player (whichever is shorter, x or
y).
I wrote this so my NPC would be in a straight //line with the player so
it could shoot its bow. Be sure to call "GetDist" before
call
this function so all the distance stuff works.
function Aim(){
if (this.distx<this.disty){
if
(x<alignx&&!onwall(x+3+this.speed,y+1.5)){
x+=this.speed;
dir=3;
}
if
(x>alignx&&!onwall(x-this.speed,y+1.5)){
x-=this.speed;
dir=1;
}
}else{
if
(y<aligny&&!onwall(x+1.5,y+3+this.speed)){
y+=this.speed;
dir=2;
}
if
(y>aligny&&!onwall(x+1.5,y-this.speed)){
y-=this.speed;
dir=0;
}
}
if((x-alignx<1&&alignx-x<1)||(y-aligny<1&&aligny-y<1))DoStuff();
}
// End of Script
Define
this.speed = How far you want the NPC to move each timeout.
alignx = The x cord that the NPC needs to align with (usually the
player's
x)
aligny = The y cord that the NPC needs to align with (usually the
player's
y)
x = The x value of the thing that needs to align with the other thing.
(heh, confusing aint it?)
y = The y value of the thing that needs to align with the other thing.
DoStuff() = The commands you want the NPC to do when its aligned (such
as shoot an arrow).
SR: 2Eii, 2G,
12
//SpinMove is the thing players do when they die. This
is written for showcharacter NPCs.
function SpinMove(){
sprite=0;
while(d<=8){
dir=(dir+3)%4;
d++;
sleep .1;
}
}
//End of Script
Define
Where you see "8", you can change that any whole number, and
thats the amount of times the NPC will change directions (so that
number
divided by 4 is the number of complete spins).
SR: 10, 12
//Catch is used to make a showcharacter NPC catch an object
(when
something is thrown at it). Note: it will not catch NPCs.
function Catch(){
sprite=23;
if (peltwithbush) carryobject bush;
else if (peltwithsign) carryobject sign;
else if (peltwithvase) carryobject vase;
else if (peltwithstone) carryobject stone;
else if (peltwithblackstone) carryobject blackstone;
else if (!peltwithnpc){
i=bombscount-1;
if (bombs[i].power==1) carryobject bomb;
else if (bombs[i].power==2) carryobject superbomb;
else if (bombs[i].power==3) carryobject joltbomb;
removebomb i;
}
}
//End of Script
Define
n/a
SR: 5, 11, 12
//Bouncing Back is done when something is hit (that bouncing
thing players and baddies do).
function BounceBack(){
Throw();
while(i<7){
i++;
if (x>playerx&&!onwall(x+2.5,y+1.5))
x+=.5;
if (x<playerx&&!onwall(x-.5,y+1.5))
x-=.5;
if (y>playery&&!onwall(x+1.5,y+2.5))
y+=.5;
if (y<playery&&!onwall(x-1.5,y-.5))
y-=.5;
sleep .05;
}
i=0;
}
//End of Script
Define
n/a
SR: 2Bii, 12
//DropInv makes the NPC drop all the items it is carrying.
function DropInv(){
while(rupees>=100){
lay goldrupee;
rupees-=100;
}
while(rupees>=30){
lay redrupee;
rupees-=30;
}
while(rupees>=5){
lay bluerupee;
rupees-=5;
}
while(rupees>0){
lay greenrupee;
rupees-=1;
}
while(darts>0){
lay darts;
darts-=5;
}
while(bombs>0){
lay bombs;
bombs-=5;
}
}
//End of Script
Define
n/a
SR: 2Bii, 4,
12
//ItemDrop is used to make the NPC drop 1 random item
(commonly
used when a baddy dies).
function ItemDrop(){
i = random(0,100);
if (i<10) lay greenrupee;
else if (i<15) lay bluerupee;
else if (i<30) lay heart;
}
//End of Script
Define
n/a
SR: 4
//MoveCheck is used to assign the variables used when you
want
to move something in a straight line towards something else.
function MoveCheck(){
if (this.distx<=.5)this.addy=this.speed;
else if (this.disty<=.5)this.addx=this.speed;
else if (this.distx>this.disty){
this.ratio=this.disty/this.distx;
this.addx=this.speed;
this.addy=this.speed*this.ratio;
}else if (this.disty>this.distx){
this.ratio=this.distx/this.disty;
this.addy=this.speed;
this.addx=this.speed*this.ratio;
}
}
//End of Script
Basically this sets up some nice ratios to ensure the NPC is going
to move in a straight line.
Define
Be sure to call GetDist before calling this function.
this.speed = how far you want the NPC to move each timeout.
SR: 2Bi, 2Biv,
2Bv, 2Bv.1,
2Bv.2, 2E,
2Ei, 2Eii,
2G, 10, 12
//Movement moves the thing (NPC, image, etc) if there is no
wall
in the way. This needs to be called in a timeout loop.
function Movement(){
if (y<this.toy&&!onwall(x+1.5,y+3+this.addy))
y+=this.addy;
if (y>this.toy&&!onwall(x+1.5,y-this.addy))
y-=this.addy;
if (x<this.tox&&!onwall(x+3+this.addx,y+1.5))
x+=this.addx;
if (x>this.tox&&!onwall(x-this.addx,y+1.5))
x-=this.addx;
}
//End of Script
Based on the location the NPC needs to move to, this will move it.
Define
Be sure to call MoveCheck before this to assign the addx and
addy vars.
this.tox = The x cord the NPC needs to move to (such as the player,
or a baddy, etc).
this.toy = The y cord the NPC needs to move to (such as the player,
or a baddy, etc).
SR: 2Bi, 2Biv,
2Bv, 2Bv.1,
2Bv.2, 2E,
2Ei, 2Eii,
2G, 10, 12
//RadialHitDetection is used when you want to check for a hit
on a circle, instead of a single point. Notice it calls the
//function
HitCheck. If you would like to see what this
detection
looks like, add in the following line of code after //"this.count++;":
showimg this.count,zolshoe5.gif,this.testx,this.testy; That will
put an image at each point on the circle checked //for a hit.
function RadialHitDetection(){
for (this.angle=3.14/2;this.count<20;this.angle+=.314){
this.testx=originx+cos(this.angle)*this.radius;
this.testy=originy+sin(this.angle)*this.radius;
this.count++;
HitCheck();
}
}
//End of Script
This creates a circle around (originx,originy) and checks to see if
any NPCs, players, or baddys are on the circle (and if they are, then
they
get hit).
Define
originx = The x cord of the center of the circle you're checking on.
originy = The y cord of the center of the circle you're checking on.
this.radius = The radius of the circle you're checking on.
SR: 2Biii, 2Biii.1,
2C, 2G, 2Gii,
2E, 5, 10,
12
// CircularMovement is for when you want to move something
on
a circle. This has to be called in a timeout loop. In my
example,
it'll show an image moving in a circle.
function CircularMovement(){
this.x1=this.orbitx1+cos(this.angle1)*this.radius;
this.y1=this.orbity1+sin(this.angle1)*this.radius;
this.angle+=this.angleincr;
showimg 1,bomb.gif,this.x1,this.y1;
timeout=this.repeatspeed;
}
}
//End of Script
This will assign an x,y value on a circle, and show an image at that
location. What you can do with it is, change
"this.angle+=this.angleincr"
to "this.angle-=this.angleincr". With it as a "+" the objects
travels
clockwise, as a "-" it moves counter-clockwise. Also, define
"this.x2",
"this.orbit2", etc to have more than one thing moving at a time.
Define
this.orbitx1 = "this.orbitx1" is the x location of the center
of the circle. Which can be the NPC's x, a defined x (such as
that
of a rock or bush), or even the player's x.
this.orbity1 = "this.orbity1" is the y location of the center
of the circle. Which can be the NPC's y, a defined y (such as
that
of a rock or bush), or even the player's y.
this.angle = "this.angle" doesn't need to start as any specific
value. It's usually starts as: 3.14/2, which will make the objetc
moving in a circle start at the bottom (ie 6 o' clock) then travel from
there.
this.radius = "this.radius" should be the radius of the circle
the object is traveling on.
this.angleincr = "this.angleincr" is the amount the object moves each
timeout. It's usually set to: .314, but it can really be any
number.
The change in this number is like changing the speed at which the
objetc
moves.
this.repeatspeed = "this.repeatspeed" is how fast the script should
loop.
SR: 2Eii, 10
//Bank Script, commonly used when a player wants to make a
bank
=P
if (playerlaysitem){
take greenrupee;
take bluerupee;
take redrupee;
take goldrupee;
if (rupees>0){
add=strtofloat(#s(bankaccount))+rupees;
setstring bankaccount,#v(add);
rupees=0;
}
}
This will make the NPC take any money the player lays, and add it to
their bank account. Their bank account will be saved in their
flag
list, so the information stays with the player.
Define
n/a
SR: 2Bi, 2C,
2E, 2Ei,
2F, 2Fi,
3, 10, 12,
13