Boomerang

Been working on this for a while… pretty tired of it, honestly. It has the capability to have higher levels, but right now that would be simply visual and only effect tiles. Eventually I will probably add sparkle trail and such for higher levels like the old versions. Dunno, suggestions are welcome, however. I might also convert the ‘step’ system to a distance, calculating from where it was originally thrown, instead of using a step counter.

Right now what it will do is mainly cutting down bushes/objects that it has the power to do so, and pick up simple drops like rupees/bombs/darts.
[php]if (created) {
// CUSTOMIZE
setstring client.boomerangstrength,1; // Strength of the boomerang Can later be changed without re-adding the weapon
this.levelspeeds = {1,1.25,1.5}; // Speeds of the boomerang for each respective level
this.leveldist = {12,18,25}; // Distance the boomerang will travel for each respective level
this.boomtiles = {
// STA,KE,TI,LES, ,REP,LAC,ETI,LES, ,STRENGTH(1 = default),LEAPS
0x2 ,0x3 ,0x12 ,0x13 , ,0x2A5,0x2A6,0x2B5,0x2B6, ,1,0 , // BUSH
0x200,0x201,0x210,0x211, ,0x70A,0x70B,0x71A,0x71B, ,1,3 , // SIGN
0x2AC,0x2AD,0x2BC,0x2BD, ,0x6EA,0x6EB,0x6FA,0x6FB, ,2,2 , // VASE
0x22 ,0x23 ,0x32 ,0x33 , ,0x72A,0x72B,0x73A,0x73B, ,2,2 , // LIGHT ROCK
0x3DE,0x3DF,0x3EE,0x3EF, ,0x72A,0x72B,0x73A,0x73B, ,3,2 , // DARK ROCK
};
// END CUSTOMIZE

setimg shiny_boomerangicon-#v(strtofloat(#s(client.boomerangstrength))).png;
setshape 1,32,32;
toweapons Boomerang;
}

if (upgradeboomerang) {
setstring client.boomerangstrength,#p(0);
setimg shiny_boomerangicon-#v(strtofloat(#s(client.boomerangstrength))).png;
}

if (weaponfired) {
if (this.boom.mode == 0) {
this.boomeranglevel = strtofloat(#s(client.boomerangstrength));
this.boom.maxdist = this.leveldist[this.boomeranglevel-1];
this.boom.maxspeed = this.levelspeeds[this.boomeranglevel-1];
setani shiny_boomerang-throw,shiny_boomerang-#v(this.boomeranglevel).png;
freezeplayer .35;
this.boom.dx = 0;
this.boom.dy = 0;
for (k=0;k<4;k++) {
if (keydown(k)) {
this.boom.dx += vecx(k);
this.boom.dy += vecy(k);
}
}
sleep .3;
this.origx = playerx+1.5;
this.origy = playery+2;
this.boom.speed = this.boom.maxspeed;
setstring this.boom.extras,;
this.boom.x = playerx + this.boom.dx;
this.boom.y = playery + this.boom.dy;
if (this.boom.dx == 0 && this.boom.dy == 0) {
this.boom.dx = vecx(playerdir);
this.boom.dy = vecy(playerdir);
} else if (abs(this.boom.dx) == 1 && abs(this.boom.dy) == 1) {
this.boom.dx /= 1.414;
this.boom.dy /= 1.414;
}
this.boom.mode = 1;
timeout = 0.05;
}
}

if (timeout) {
if (this.boom.mode > 0) {
if (this.boom.mode == 1) {
this.dx = (this.boom.x+1.5) - this.origx;
this.dy = (this.boom.y+2) - this.origy;
this.dist = (this.dx^2 + this.dy^2)^.5;
if (this.dist >= this.boom.maxdist) this.boom.mode = 2;
else if (this.dist >= this.boom.maxdist-5) this.boom.speed = .9 - (this.boom.maxspeed > 1 ? ((this.boom.maxspeed-1)/.25).05 : 0);
else this.boom.speed = this.boom.maxspeed;
this.boom.x += this.boom.dxthis.boom.speed;
this.boom.y += this.boom.dy
this.boom.speed;
showani 0,this.boom.x,this.boom.y,0,shiny_boomerang,shiny_boomerang-#v(this.boomeranglevel).png;
if (onwall(this.boom.x+1.5+this.boom.dxthis.boom.speed,this.boom.y+2+this.boom.dythis.boom.speed)) {
if (!(tiles[this.boom.x+1.5+this.boom.dxthis.boom.speed,this.boom.y+2+this.boom.dythis.boom.speed] in this.boomtiles)) {
this.boom.mode = 2;
putleaps 4,this.boom.x+.5,this.boom.y+1;
play2 arrowon.wav,this.boom.x+1.5,this.boom.y+2,1;
}
}
} else if (this.boom.mode == 2) {
this.dx = (playerx+1.5) - (this.boom.x+1.5);
this.dy = (playery+2) - (this.boom.y+2);
this.dist = (this.dx^2 + this.dy^2)^.5;
if (this.dist > this.boom.maxdist-5) this.boom.speed = 1.1 + (this.boom.maxspeed > 1 ? ((this.boom.maxspeed-1)/.25).05 : 0);
else this.boom.speed = this.boom.maxspeed;
if (this.boom.speed > this.boom.maxspeed) this.boom.speed = this.boom.maxspeed;
this.boom.x += (this.dx/this.dist)this.boom.speed;
this.boom.y += (this.dy/this.dist)this.boom.speed;
if (this.dist < 2.5) {
for (i=0;i<int(sarraylen(this.boom.extras)/3);i++) {
if (strtofloat(#I(this.boom.extras,i
3)) == 0) playerrupees += 1;
else if (strtofloat(#I(this.boom.extras,i
3)) == 1) playerrupees += 5;
else if (strtofloat(#I(this.boom.extras,i3)) == 2) playerrupees += 30;
else if (strtofloat(#I(this.boom.extras,i
3)) == 3) playerbombs += 5;
else if (strtofloat(#I(this.boom.extras,i3)) == 4) playerdarts += 5;
else if (strtofloat(#I(this.boom.extras,i
3)) == 5) playerhearts += 1;
else if (strtofloat(#I(this.boom.extras,i*3)) == 19) playerrupees += 100;
play extra.wav;
}
this.boom.mode = 0;
hideimg 0;
} else {
showani 0,this.boom.x,this.boom.y,0,shiny_boomerang,shiny_boomerang-#v(this.boomeranglevel).png;
changeimgvis 0,1;
}
}
CheckDrops();
CheckTiles();
timeout = 0.05;
} else hideimgs 10,100;
}

function CheckDrops() {
this.checkitem = testitem(this.boom.x+1.5,this.boom.y+2);
if (this.checkitem >= 0) {
insertstring this.boom.extras,0,#v(random(-1,1));
insertstring this.boom.extras,0,#v(random(-1,1));
insertstring this.boom.extras,0,#v(items[this.checkitem].type);
take2 this.checkitem;
play extra.wav;
}
for (i=0;i<int(sarraylen(this.boom.extras)/3);i++) {
showimg 10+i,shiny_drops-1.png,this.boom.x+strtofloat(#I(this.boom.extras,i3+1))+.5,this.boom.y+strtofloat(#I(this.boom.extras,i3+2))+.5;
changeimgpart 10+i,0,0,32,32;
changeimgvis 10+i,0;
if (strtofloat(#I(this.boom.extras,i3)) == 0) changeimgpart 10+i,032,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 1) changeimgpart 10+i,132,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 2) changeimgpart 10+i,232,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 3) changeimgpart 10+i,332,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 4) changeimgpart 10+i,432,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 5) changeimgpart 10+i,532,0,32,32;
else if (strtofloat(#I(this.boom.extras,i3)) == 19) changeimgpart 10+i,632,0,32,32;
}
}

function CheckTiles() {
for (i=0;i<9;i++) {
this.objtile = -1;
for (j=0;j<int(arraylen(this.boomtiles)/12);j++) {
if (tiles[this.boom.x+(i%3),this.boom.y+int(i/3)] == this.boomtiles[j12]) {
this.checkx = int(this.boom.x+(i%3));
this.checky = int(this.boom.y+int(i/3));
this.objtile = j;
break;
}
}
if (this.objtile >= 0) {
if (this.boomeranglevel < this.boomtiles[10+this.objtile
12]) return;
putleaps this.boomtiles[11+this.objtile12],this.checkx,this.checky;
for (j=0;j<4;j++) {
tiles[this.checkx+(j%2),this.checky+int(j/2)] = this.boomtiles[this.objtile
12+5+j];
}
updateboard this.checkx,this.checky,2,2;
}
}
}[/php]
If you’re curious on how to customize the tile array, take a look here:
http://forums.graal.in/forums/showthread.php?t=1760

UPDATE:
I’ve added a command that will allow you to update the boomerang externally from another NPC. All you have to do is call this script from another NPC(perhaps a blacksmith or something). It does not calculate level automatically, you will have to provide the desired level yourself.
[php]for (i=0;i<weaponscount;i++) {
if (strequals(#w(i),Boomerang)) {
callweapon i,upgradeboomerang,3; // UPGRADES THE BOOMERANG, LAST NUMBER IS DESIRED NEW LEVEL
break;
}
}[/php]

Also, you’ll find the other images you may need in later posts in this thread. Scroll down to find them.[/b]

Explains the “this.boom” from earlier, thought you were talking about some sort of bomb. o_o

Thanks for posting things to help the newbies. I’m not too good at that, I make them come to me instead and even then its usually “HoW dO I mAEK GUn?!”

I found I simply had to check if this.objtile was >= 0 :slight_smile:
It was driving me nuts for a while, heh.

Only take a few moments.
I assume between the both of us, we’ve made about 30 separate Hookshot scripts. o_o

Mind you, their methods are a dime a dozen. The two primary types are:
Fixed player position “playerx = 32+this.i”
Relative player position. “playerx += this.move”

Only fault with some hookshot scripts is knowing when to stop;
Otherwise you could end up zooming around the screen uncontrollably. :smiley:

Also does this mean to indend to poke at Waffles, Nalin? :open_mouth:

-edit- Downside with Graal is we’re bound by the limited ideas of Zelda. Such as “Sword/Shield/Boomerang/Hookshot/Bomb/Bow”
We need something better, more innovative, fun, that’s NOT a gun (or a crappy ass train, I’m looking at you Nintendo).

I started a Megaman server, remember, and I also started a Portal server ala that Flash remake of Portal.

I missed that portal server. Never got to see it.

And there has been attempts to make a pokemon server and a turnbased server and so on.

I think he means just more creative NPCs :slight_smile:

There was always the Trident. That was pretty cool in terms of ideas, like being able to pick up bushes with it to do more damage(or bombs).

For some reason it breaks everything when the strength is at 1.

Oh ya… I forgot to put that check in :smiley:

;]

I’ll fix in the morning.

Okay, updated the script with some major overhauls(the update is in the original post):

• Fixed the noted bug of being able to crush anything with the boomerang, regardless of level

• Converted the steps to distance checks. This means you can provide a max distance the boomerang will travel from where it was thrown, which is much more easier to customize than calculating steps vs. speed and such.

• Gave boomerang levels more support – being able to specify speed and distance for each level

• Made the boomerang more functional for speeds other than 1(though I don’t recommend going UNDER .75) which involved the slowing down after a certain distance. Before if it was under 1 it would either stop, or if it was over 1 no slowdown was noticeable at all.

• Fixed a simple drop bug that was registering the wrong items.

Also attached images for higher level boomerangs, though feel free to use whatever you want. Like originally said I may eventually add trails.

Now tiles set to lvl2 and 3 don’t change.

___Merged doublepost__________________

nvm

Okay, updated it with the same fix as the Hammer.
Also updated it with the same functionality of being able to upgrade it from external NPCs.

Good thing I caught that bug or when all the newbs put them on their servers find out it’s not working and flip out. Now you aren’t going to be harassed by an army of scavengers.

___Merged doublepost__________________

It’d be awesome if these could hurt baddies/NPCs and other players.
Or if the boomerang sent a triggeraction so it can press buttons the player cannot or something.

Great job on this but Like Spoon said, add the option to hurt players and baddies, annd, when it hits a player it freezes them for 1 second :o

lol, when charity scripts turn into forced labour.

Triggeraction, involving a system NPC on the other player to react to it.
If he did post such a thing, there’s a chance that 90% of the people asking for it, couldn’t understand how to use it properly or at all. -_o Fairly frequent, especially if the NPC has to be in multiple parts.

Apparently there is still a major bug, according to Nalin… but I’m so tired of these two scripts lol. I’ll worry about fixing them later.

I forgot all about players/baddies, and Beholder is right – there is no ‘simple’ way to do freezing without a core triggeraction NPC to handle the triggeractions. Could still hurt for 0 damage, which would cause recoil, which would freeze the player for a moment. Honestly, I think freezing the player any longer would be pretty overpowered; freezing works well in single-player games, not so well in multiplayer.

They’re both similar (hookshot and boomerang) because they rely on looping and are delt in moving positions away from the player.