This is a simple script for a new weapon. It is a spell that shoots a weapon in all cardinal and ordinal directions. It started out just being something to test the new possibility of placing lweapons, but evolved enough for me to think it at least a decent script. Different levels of the weapon can have completely different attributes, thanks to the flexibility offered by internal Item arguments. It's not the best script in the world, but it might give people some ideas. Additionally, it could serve as a sort of lower-level Din's Fire or something.

NOTE: The script refers to it as a "Beam", while it's not necessarily that in effect. I didn't feel like changing every instance of 'beam' just for continuity. :p

NOTE II: Magic consumption is not handled internally to the script. If you want it to drain magic just make the appropriate item do so.

LAST NOTE: I have the projectiles in this script set as magic. You can change that by modifying the value in the CreateLWeapon declarations. I had meant to have this be changeable through an argument, but ran out of them.


Youtube Video of Two Different Levels of the Weapon


import "std.zh"

Declare the following at the global level.

Code:
//Multi-Directional Beam Variable Declarations
int item_mdbeam_used = 0; // For detecting if the multi-directional beam is used.
int item_mdbeam_d0 = 0; // These transfers multi-directional beam's D0 - D7 to global handler.
int item_mdbeam_d1 = 0; 
int item_mdbeam_d2 = 0; 
int item_mdbeam_d3 = 0; 
int item_mdbeam_d4 = 0;
int item_mdbeam_d5 = 0;
int item_mdbeam_d6 = 0;
int item_mdbeam_d7 = 0;
int item_mdbeam_a = 0; // Multi-directional beam's internal handler A.
Declare the following as item script. Read comments to know what the Item arguments do. Change item arguments as needed for necessary behaviour.

Code:
//##====================================##
//##   Multi-Directional Beam Script    ##
//##         Item Startup Code          ##
//##   This item will make Link shoot a ##
//##      Beam in all 8 Directions.     ##
//##     Speed varies with each shot.   ##
//##                                    ##
//##  D0 = Damage Done By Projectiles   ##
//##    D1 = Amount of Time to Pause    ##
//##  D2 = Tile that Begins Sequences   ##
//## D3 = Number of Frames Per Sequence ##
//##         D4 = Animation Speed       ##
//##           D5 = Color Set           ##
//##           D6 = Beam Speed          ##
//##           D7 = Diagonal Beam Speed ##
//##                #000                ##
//##====================================##
// Note: D2 begins the graphics needed for each and every different beam.
// D3 adds the number of additional frames to each beam. So if you had D2
// as 400 and D3 as 3, your first beam animation would be 400, 401, 402.
// Second would be 403, 404, 405. And so on.

item script item_mdbeam{
    void run(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8){

    if (item_mdbeam_used == 0){
    
    item_mdbeam_d0 = arg1;
    item_mdbeam_d1 = arg2;
    item_mdbeam_d2 = arg3;
    item_mdbeam_d3 = arg4;
    item_mdbeam_d4 = arg5;
    item_mdbeam_d5 = arg6;
    item_mdbeam_d6 = arg7;
    item_mdbeam_d7 = arg8;
    item_mdbeam_used = 1;
    }

    }
}

//##====================================##
//##   Multi-Directional Beam Script    ##
//##        End of Item Segment         ##
//##====================================##
Put the following somewhere in a Global Script.
Note: Be sure to have Waitframe(); at the end of your global script!
Thanks to Gleeok for helping me shorten it!


Code:
//##====================================##
//##   Multi-Directional Beam Script    ##
//##           Global Handler           ##
//##This segment will make Link shoot a ##
//##      Beam in all 8 Directions.     ##
//##                                    ##
//##====================================##

        
    if (item_mdbeam_used == 1){
    item_mdbeam_a = item_mdbeam_d1;

for(int i; i<8;i++){
    lweapon beam3 = Screen->CreateLWeapon(13);
    beam3->X = Link->X; beam3->Y = Link->Y; beam3->Z = Link->Z;
    beam3->Dir = i;
    if(i<4)beam3->Step = item_mdbeam_d6;
    else beam3->Step = item_mdbeam_d7;
    beam3->Damage = item_mdbeam_d0;
    beam3->OriginalTile = item_mdbeam_d2 + (item_mdbeam_d3*i);
    beam3->ASpeed = item_mdbeam_d4;
    beam3->NumFrames = item_mdbeam_d3;
    beam3->Frame = 0;
    beam3->FlashCSet = 8;
    beam3->CSet = item_mdbeam_d5;
}

    item_mdbeam_used = 0; 
}


    if(item_mdbeam_a > 0){
    item_mdbeam_a--;
    Link->Action = 3;
    Link->Item[250] = 1;

    if(Link->Dir == 0)Screen->DrawTile(1, Link->X, Link->Y, 340, 1, 1, 6, 1, 0, 0, 0, 0, 1, 128);

    if(Link->Dir == 1)Screen->DrawTile(1, Link->X, Link->Y, 341, 1, 1, 6, 1, 0, 0, 0, 0, 1, 128);

    if(Link->Dir == 2)Screen->DrawTile(1, Link->X, Link->Y, 342, 1, 1, 6, 1, 0, 0, 0, 0, 1, 128);

    if(Link->Dir == 3)Screen->DrawTile(1, Link->X, Link->Y, 343, 1, 1, 6, 1, 0, 0, 0, 0, 1, 128);

 
    } else {
    Link->Item[250] = 0;
    if (Link->Action == 3) Link->Action = 0;
}

//##====================================##
//##   Multi-Directional Beam Script    ##
//##      End of Global Segment         ##
//##====================================##
I don't consider myself to be a veteran scriptor yet, so if some of the more keen scriptors know ways to reduce and optimize this, please share them.