CODE
const int WPS_FIREARROW = 88; //The id of the fire arrow weapon sprite.
const int WPS_FIRESPARKLE = 89; //The id of the fire arrow sparkle sprite.
const int WPS_FIRE = 35; //The ID of the flame sprite.
const int LW_SPECIALARROW = 31; //The ID of the scripted weapon slot.
int firelevel = 0; //this is the current level of the fire arrow link has.
bool truearrows = true; //if your using arrows as a separte counter change this to true.
bool needbow = true; //if link requires the bow to fire these leave this true.
//this function makes the game trigger the explosion by use of collision detection.
bool collided(lweapon arrow){
int x1 = arrow->X + arrow->HitXOffset;
int y1 = arrow->Y + arrow->HitYOffset;
int x2 = x1 + arrow->HitWidth;
int y2 = y1 + arrow->HitHeight;
for(int i = Screen->NumNPCs(); i > 0; i--){
npc enemy = Screen->LoadNPC(i);
if(enemy->isValid()){
int x3 = enemy->X + enemy->HitXOffset;
int y3 = enemy->Y + enemy->HitYOffset;
int x4 = x3 + enemy->HitWidth;
int y4 = y3 + enemy->HitHeight;
if(RectCollision(x1,y1,x2,y2,x3,y3,x4,y4)) return(true);
}
}
if(!RectCollision(16,16,ComboX(175),ComboY(175),x1,y1,x2,y2)) return(true);
else return(false);
}
//this script is the heart of the script hand handles the arrows sparkles and bursting them into flames.
global script Slot2{
void run(){
while(true){
if(firelevel != 0){
for(int i = Screen->NumLWeapons(); i > 0; i--){
lweapon arrow = Screen->LoadLWeapon(i);
if(arrow->isValid()){
if(arrow->ID == LW_SPECIALARROW && arrow->Misc[3] == 1){
if(collided(arrow)){
if(firelevel == 1){
lweapon flame = CreateLWeaponAt(LW_FIRE,arrow->X,arrow->Y);
flame->UseSprite(WPS_FIRE);
flame->Damage = arrow->Misc[0];
flame->Dir = 8;
flame->Step = 0;
arrow->DeadState = WDS_DEAD;
}
else{
lweapon flame[8];
for(int i = 0; i < 8; i++){
flame[i] = CreateLWeaponAt(LW_FIRE,arrow->X,arrow->Y);
flame[i]->UseSprite(WPS_FIRE);
flame[i]->Damage = arrow->Misc[0];
flame[i]->Dir = i;
flame[i]->Angular = true;
flame[i]->Angle = DegtoRad(i * 45);
flame[i]->Step = 80;
}
arrow->DeadState = WDS_DEAD;
}
}
else if(arrow->Misc[2] % 4 == 0){
lweapon sparkle = CreateLWeaponAt(LW_FIRESPARKLE,arrow->X,arrow->Y);
sparkle->UseSprite(WPS_FIRESPARKLE);
sparkle->Damage = arrow->Misc[1];
}
arrow->Misc[2]++;
}
}
}
}
Waitframe();
}
}
}
//this script controls the level of the fire arrow. Attach it to the pick up slot.
item script FireArrowPickUp{
void run(){
if(firelevel < this->Level) firelevel = this->Level;
}
}
//this is the action script for the item. It causes the arrows to be fired and several miscellaneous attributes set. Nothing more.
item script FireArrowAction{
void run(int firedamage, int sparkledamage, int step, int frames){
if(firelevel <= 0) firelevel = this->Level;
if(needbow && !(Link->Item[I_BOW1] || Link->Item[I_BOW2])) Quit();
if(truearrows && Game->Counter[CR_ARROWS] > 0){
Game->Counter[CR_ARROWS]--;
shoot(firedamage, sparkledamage, step, frames,this);
}
else if(!truearrows && Game->Counter[CR_RUPEES] > 0){
Game->Counter[CR_RUPEES]--;
shoot(firedamage, sparkledamage, step, frames,this);
}
}
void shoot(int firedamage, int sparkledamage, int step, int frames, itemdata this){
Link->Action = LA_ATTACKING;
Game->PlaySound(SFX_ARROW);
lweapon wpn = NextToLink(LW_SPECIALARROW, 0);
wpn->UseSprite(WPS_FIREARROW);
wpn->Dir = Link->Dir;
if(wpn->Dir == DIR_DOWN || wpn->Dir == DIR_LEFT) wpn->Flip = 3;
if(wpn->Dir == DIR_LEFT || wpn->Dir == DIR_RIGHT) wpn->OriginalTile += frames;
if(step == 0){
if(Link->Item[I_BOW2]) wpn->Step = 600;
else if(Link->Item[I_BOW1]) wpn->Step = 300;
}
else wpn->Step = step;
wpn->CollDetection = false;
wpn->Damage = this->Power;
//now about the miscellaneous attribute here. This is where the magic happens. Details below.
wpn->Misc[0] = firedamage;
wpn->Misc[1] = sparkledamage;
wpn->Misc[2] = -3;
wpn->Misc[3] = 1;
}
}
const int WPS_FIRESPARKLE = 89; //The id of the fire arrow sparkle sprite.
const int WPS_FIRE = 35; //The ID of the flame sprite.
const int LW_SPECIALARROW = 31; //The ID of the scripted weapon slot.
int firelevel = 0; //this is the current level of the fire arrow link has.
bool truearrows = true; //if your using arrows as a separte counter change this to true.
bool needbow = true; //if link requires the bow to fire these leave this true.
//this function makes the game trigger the explosion by use of collision detection.
bool collided(lweapon arrow){
int x1 = arrow->X + arrow->HitXOffset;
int y1 = arrow->Y + arrow->HitYOffset;
int x2 = x1 + arrow->HitWidth;
int y2 = y1 + arrow->HitHeight;
for(int i = Screen->NumNPCs(); i > 0; i--){
npc enemy = Screen->LoadNPC(i);
if(enemy->isValid()){
int x3 = enemy->X + enemy->HitXOffset;
int y3 = enemy->Y + enemy->HitYOffset;
int x4 = x3 + enemy->HitWidth;
int y4 = y3 + enemy->HitHeight;
if(RectCollision(x1,y1,x2,y2,x3,y3,x4,y4)) return(true);
}
}
if(!RectCollision(16,16,ComboX(175),ComboY(175),x1,y1,x2,y2)) return(true);
else return(false);
}
//this script is the heart of the script hand handles the arrows sparkles and bursting them into flames.
global script Slot2{
void run(){
while(true){
if(firelevel != 0){
for(int i = Screen->NumLWeapons(); i > 0; i--){
lweapon arrow = Screen->LoadLWeapon(i);
if(arrow->isValid()){
if(arrow->ID == LW_SPECIALARROW && arrow->Misc[3] == 1){
if(collided(arrow)){
if(firelevel == 1){
lweapon flame = CreateLWeaponAt(LW_FIRE,arrow->X,arrow->Y);
flame->UseSprite(WPS_FIRE);
flame->Damage = arrow->Misc[0];
flame->Dir = 8;
flame->Step = 0;
arrow->DeadState = WDS_DEAD;
}
else{
lweapon flame[8];
for(int i = 0; i < 8; i++){
flame[i] = CreateLWeaponAt(LW_FIRE,arrow->X,arrow->Y);
flame[i]->UseSprite(WPS_FIRE);
flame[i]->Damage = arrow->Misc[0];
flame[i]->Dir = i;
flame[i]->Angular = true;
flame[i]->Angle = DegtoRad(i * 45);
flame[i]->Step = 80;
}
arrow->DeadState = WDS_DEAD;
}
}
else if(arrow->Misc[2] % 4 == 0){
lweapon sparkle = CreateLWeaponAt(LW_FIRESPARKLE,arrow->X,arrow->Y);
sparkle->UseSprite(WPS_FIRESPARKLE);
sparkle->Damage = arrow->Misc[1];
}
arrow->Misc[2]++;
}
}
}
}
Waitframe();
}
}
}
//this script controls the level of the fire arrow. Attach it to the pick up slot.
item script FireArrowPickUp{
void run(){
if(firelevel < this->Level) firelevel = this->Level;
}
}
//this is the action script for the item. It causes the arrows to be fired and several miscellaneous attributes set. Nothing more.
item script FireArrowAction{
void run(int firedamage, int sparkledamage, int step, int frames){
if(firelevel <= 0) firelevel = this->Level;
if(needbow && !(Link->Item[I_BOW1] || Link->Item[I_BOW2])) Quit();
if(truearrows && Game->Counter[CR_ARROWS] > 0){
Game->Counter[CR_ARROWS]--;
shoot(firedamage, sparkledamage, step, frames,this);
}
else if(!truearrows && Game->Counter[CR_RUPEES] > 0){
Game->Counter[CR_RUPEES]--;
shoot(firedamage, sparkledamage, step, frames,this);
}
}
void shoot(int firedamage, int sparkledamage, int step, int frames, itemdata this){
Link->Action = LA_ATTACKING;
Game->PlaySound(SFX_ARROW);
lweapon wpn = NextToLink(LW_SPECIALARROW, 0);
wpn->UseSprite(WPS_FIREARROW);
wpn->Dir = Link->Dir;
if(wpn->Dir == DIR_DOWN || wpn->Dir == DIR_LEFT) wpn->Flip = 3;
if(wpn->Dir == DIR_LEFT || wpn->Dir == DIR_RIGHT) wpn->OriginalTile += frames;
if(step == 0){
if(Link->Item[I_BOW2]) wpn->Step = 600;
else if(Link->Item[I_BOW1]) wpn->Step = 300;
}
else wpn->Step = step;
wpn->CollDetection = false;
wpn->Damage = this->Power;
//now about the miscellaneous attribute here. This is where the magic happens. Details below.
wpn->Misc[0] = firedamage;
wpn->Misc[1] = sparkledamage;
wpn->Misc[2] = -3;
wpn->Misc[3] = 1;
}
}
Okay now it''s time to explain how this baby works. First create a custom item class item and check the equipment box. Set level to either 1 or 2 and power to the arrow's damage. Attach the scripts and now for attributes. D0 = the flame damage, D1 = the sparkle damage, D2 = the speed of the arrow. 300 is the speed of the shortbow, and 600 is the speed of the longbow. Leave this at 0 to use the bow speed. D3 = the number of frames for the fire arrows. Yup that's right they can be animated. Now for two minor details. Misc[3] identifies the scripted weapon as a fire arrow. And number 2 is used to delay the creation of sparkles.
It's pretty freaking awesome if you ask me. I love this item. And this is only version 1, I'll submit version 2 later this month. Details on that are a secret to everybody.
Oh and if you need help setting it up Just PM me or better yet use the Script Database Help forum. Enjoy!


