function SpinMove(){ sprite=0; this.count=0; while(this.count<8){ dir=( dir+3)%4; this.count++; sleep .1; } sprite=40; Reward(); } |
First of all I set the sprite to 0, because I like to see the spin move done with that sprite . You can set it to anything you like. Then I initialize my count variable, this.count to 0. Next a while loop is started and will execute as long as this.count is less that 8. I chose 8 because there are four directions a NPC can face, and I want it to turn around two complete times, 2*4=8. the dir thing with the % mod works just like it does for sprites when animating the walking of your NPC. Then this.count increases by 1, and the baddy sleeps for .1 seconds. After the while loop has executed, the NPC is done spinning, and is now dead, so I set it to the dead sprite, which is 40. Instead of Reward(), you can use one of the two following functions to reward your player for killing the baddy. Or, you can remove this entirely. |
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; } } |
This function makes the NPC drop everything it is currently carrying. So you would have to first give it some items to carry in its Initialize() function. Instead of just using the lay command, try using lay2 and having the x and y cords of the items be random so they items scatter. |
function ItemDrop(){ i = random(0,100); if (i<10) lay greenrupee; else if (i<15) lay bluerupee; else if (i<30) lay heart; } |
This function makes the NPC drop one random item. You can feel free to adjust the frequency as well as what items specifically it drops. Again, try using lay2 and maybe add a little randomness to it. |