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.dythis.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,i3)) == 0) playerrupees += 1;
else if (strtofloat(#I(this.boom.extras,i3)) == 1) playerrupees += 5;
else if (strtofloat(#I(this.boom.extras,i3)) == 2) playerrupees += 30;
else if (strtofloat(#I(this.boom.extras,i3)) == 3) playerbombs += 5;
else if (strtofloat(#I(this.boom.extras,i3)) == 4) playerdarts += 5;
else if (strtofloat(#I(this.boom.extras,i3)) == 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.objtile12]) 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.objtile12+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]