Customizable hammer. Should be pretty obvious with the comments how to customize it, but if you have any questions just post.
[php]if (created) {
toweapons Hammer;
setstring client.hammerstrength,1; // Strength of the hammer. Can later be changed without re-adding the weapon.
setimg shiny_hammericon-#v(strtofloat(#s(client.hammerstrength))).png;
this.staketiles = {
// STA,KE,TI,LES, ,REP,LAC,ETI,LES, ,STRENGTH(1 = default),LEAPS(-1 = no leaps)
0x14A,0x14B,0x15A,0x15B, ,0x70A,0x70B,0x71A,0x71B, ,1,-1, // STAKE
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
0x674,0x675,0x684,0x685, ,0x70A,0x70B,0x71A,0x71B, ,1,-1, // LIGHT STAKE
0x7E0,0x7E1,0x7F0,0x7F1, ,0xFE5,0xFE6,0xFF5,0xFF6, ,2,-1, // SNOW STAKE
0xB4A,0xB4B,0xB5A,0xB5B, ,0xC50,0xC51,0xC60,0xC61, ,3,-1, // VOLCANO STAKE
0x22 ,0x23 ,0x32 ,0x33 , ,0x72A,0x72B,0x73A,0x73B, ,2,2 , // LIGHT ROCK
0x3DE,0x3DF,0x3EE,0x3EF, ,0x72A,0x72B,0x73A,0x73B, ,3,2 , // DARK ROCK
};
}
if (upgradehammer) {
setstring client.hammerstrength,#p(0);
setimg shiny_hammericon-#v(strtofloat(#s(client.hammerstrength))).png;
}
if (weaponfired) {
this.hammerlevel = strtofloat(#s(client.hammerstrength));
setani shiny_hammer,shiny_hammer-#v(this.hammerlevel).png;
freezeplayer .45;
this.checkx = int(playerx+.95)+vecx(playerdir)*2;
this.checky = int(playery+1.25)+vecy(playerdir)*2;
this.stake = -1;
for (i=0;i<arraylen(this.staketiles);i++) {
if (tiles[this.checkx,this.checky] == this.staketiles[i*12]) {
this.stake = i;
break;
}
}
sleep .35;
if (this.stake >= 0 && this.hammerlevel >= this.staketiles[10+this.stake*12]) ReplaceStake();
else play lift.wav;
}
function ReplaceStake() {
for (i=0;i<4;i++) {
if (tiles[this.checkx+(i%2),this.checky+int(i/2)] != this.staketiles[this.stake12+i]) {
play lift.wav;
return;
}
}
for (i=0;i<4;i++) {
tiles[this.checkx+(i%2),this.checky+int(i/2)] = this.staketiles[5+this.stake12+i];
}
if (this.staketiles[11+this.stake12] >= 0) putleaps this.staketiles[11+this.stake12],this.checkx,this.checky;
updateboard this.checkx,this.checky,2,2;
play sign.wav;
}[/php]
Here is the format of the tiles that are used. If you wish to add more stakes you will have to lay out the tiles like this before you get the hex code:
[attach]562[/attach]
Don’t forget to add the , , between the STAKE and REPLACE tiles in the array!
I’ve also attached the gani and images you’ll need.
UPDATE:
I’ve added a command that will allow you to update the hammer 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),Hammer)) {
callweapon i,upgradehammer,3; // UPGRADES THE HAMMER, LAST NUMBER IS DESIRED NEW LEVEL
break;
}
}[/php]