Homing Missile

Name: Homing Missile
Type: Weapon
Author: John Doe
Description: Player fires a missile that chases the first player it finds.
Notes: Haven't tested online. Required images attached.

[code]if (playertouchsme) {
toweapons Homing Missile;
hidelocal;
}
if (playerenters) {
show;
hideimg 1;
this.active = 0;
this.accel = .1;
this.maxaccel = 1;
timeout = 0;
}

if (weaponfired) {
if (playerbombs >= 1 && playerdarts >= 3 && this.active == 0) {
// playerbombs -= 1;
// playerdarts -= 3;
freezeplayer .6;
timeout = .5;
setbow hominggun.png;
playersprite = 33;
this.flyx = playerx + 1.5;
this.flyy = playery + 2;
this.mx = 0; this.my = 0;
if (playerdir == 0) { this.flyy -= 2; this.my = -this.accel; }
if (playerdir == 1) { this.flyx -= 2; this.mx = -this.accel; }
if (playerdir == 2) { this.flyy += 2; this.my = this.accel; }
if (playerdir == 3) { this.flyx += 2; this.mx = this.accel; }
this.ax = this.mx; this.ay = this.my;
this.lock = 0;
this.locktype = 0;
this.lastplayers = playerscount;
this.lastcomps = compuscount;
this.active = 1;
} else if (this.active == 1) {
this.active = 2;
}
}

if (timeout && this.active > 0) {
if (this.lastplayers != playerscount || this.lastcomps != compuscount) this.locktype = 0;
if (this.locktype == 0) {
distance = 4096;
lock = -1; locktype = 0;

for (i = 1; i < playerscount; i++) {
j = players[i].x + 1.5 - this.flyx; j = abs(j * j);
k = players[i].y + 2 - this.flyy; k = abs(k * k);
if (j + k < distance) {
lock = i; locktype = 1; distance = j + k;
}
}

for (i = 0; i < compuscount; i++) {
j = compus[i].x + 1.5 - this.flyx; j = abs(j * j);
k = compus[i].y + 1.5 - this.flyy; k = abs(k * k);
if (j + k < distance) {
lock = i; locktype = 2; distance = j + k;
}
}
this.lastplayers = playerscount;
this.lastcomps = compuscount;
this.lock = lock;
this.locktype = locktype;
}

i = this.lock;
if (this.locktype == 1) {
if (players[i].x + 2 > this.flyx) this.ax = this.accel;
else if (players[i].x + 1 < this.flyx) this.ax = -this.accel;
else this.ax = 0;
if (players[i].y + 2.5 > this.flyy) this.ay = this.accel;
else if (players[i].y + 1.5 < this.flyy) this.ay = -this.accel;
else this.ay = 0;
} else if (this.locktype == 2) {
if (compus[i].x + 2.5 > this.flyx) this.ax = this.accel;
else if (compus[i].x + 1.5 < this.flyx) this.ax = -this.accel;
else this.ax = 0;
if (compus[i].y + 2.5 > this.flyy) this.ay = this.accel;
else if (compus[i].y + 1.5 < this.flyy) this.ay = -this.accel;
else this.ay = 0;
}

if (abs(this.ax+this.mx) <= this.maxaccel) this.mx += this.ax;
if (abs(this.ay+this.my) <= this.maxaccel) this.my += this.ay;
this.flyx += this.mx; this.flyy += this.my;

hit = 0;
j = playerscount; if (j < compuscount) j = compuscount;
for (i = 0; i < j; i++) {
if (i < playerscount)
if (abs(this.flyx-players[i].x-1.5)<1.5 && abs(this.flyy-players[i].y-2)<1.5) hit = 1;
if (i < compuscount)
if (abs(this.flyx-compus[i].x-1.5)<1.5 && abs(this.flyy-compus[i].y-2)<1.5) hit = 1;
}
if (this.active == 2 || onwall(this.flyx,this.flyy)) hit = 1;

if (hit == 1) {
hideimg 1;
this.active = 0;
putexplosion 2,this.flyx-1,this.flyy-1;
} else {
putx = this.flyx - .3125;
puty = this.flyy - .3125;
left = 0; wide = 30;
top = 0; high = 30;
if (this.mx == 0) { left = 30; wide = 9; }
if (this.mx > 0) { left = 39; putx -= 1.5625; }
if (this.my == 0) { top = 30; high = 9; }
if (this.my > 0) { top = 39; puty -= 1.5625; }
showimg 1,homing.png,putx,puty;
changeimgpart 1,left,top,wide,high;
timeout = .05;
}
}
[/code]

[attachment deleted by admin]

Re: Homing Missile

im brand new to all this and i am excited about making my on Graal game… i just noticed that this attachment was deleted and I was kinda hoping someone could re-add it because i wanted to try it out

Re: Homing Missile

The attachments that were deleted were just the images.
Replace the first image in the script with with “wbow4.png”
Replace the second image with any image you may have, like an ‘orb.gif’ or ‘block.png’. Or could be originally and make your own image (gif/png/mng), just make sure that the palette is 256 colors or less. (So don’t use MS Paint or Photoshop to save.)

Re: Homing Missile

ok! one question 256 or less? (on the colors) is this a requirement for the Gserver to read the png properly or are you just suggesting to use 256 for filesize/lag issues?

Re: Homing Missile

Graal operates at that specific setting. If it isn’t set at that, the image will not be processed by the game and you will only see the “character outline” image in the editor.

The computer where I had these files is currently out of commission. But, for the sake of ease, I’ll see if this computer happens to have them cached. I don’t actually use most of the weapons that I posted; they don’t fit my theme. However, I did post them for those who might have/make some use for them.

No luck. I’m starting to get caught up with bills, a bit, so I’ll be able to order a new mobo for my computer and get it running, again. Unfortunately, it’ll probably be early June by the time I have it and I’m sure you don’t want to wait that long. Just use Behòlder’s solution and you’ll be fine.