Jump to content

Photo

Samus' Power Beam


  • Please log in to reply
37 replies to this topic

#1 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 04:24 PM

I need a power beam for a Samus, but not sword like.
Basically, all I'm asking for is an arrow, with no ammo, and more than one instance of it possible on a screen. Possible? Or if it is already in script form, or easily made without a script without just changing the graphics of another item, please direct.

#2 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 04:27 PM

I'm happy to script for Metroid =D

This would take me about 10 minutes too.
Did you want it to charge up?

EDIT: Oh, and I could make it so there's a slight delay between pressing the button, so as you can't put a hundred or something stupid shots on the screen if you like too?
And the charged up version could use the silver arrow so as to trigger different flags?

Dammit I'm getting ahead of myself...

EDIT: Oh, also, will you be using the 'Can Select A/B Subscreen Item' thing, or is this just going to be one button or what?
Or is it not even going to be an item?

You know, I could just make it so that when you press A, this happens, and save the need for items.

*sigh*
I really am getting ahead of myself now =P

EDIT:
CODE
//Inputs
const int Beam1ID        = 0;    //Make a new weapon sprite with the un-charged power-beams'  data, and set its ID value here
const int Beam2ID        = 0;    //And the same for the charged power-beams' data here
const int BeamSFX        = 0;    //Sound effect to play when beam is fired

const int BeamSpeed        = 3;    //Speed for beams to fly at goes here
const int Beam1Damage    = 2;    //Damage for un-charged beam here
const int Beam2Damage    = 4;    //Damage for charged beam here
const int BeamChargeMax    = 20;    //Time to wait for beam to charge up here
const int BeamDelayMax    = 5;    //Delay in which Samus cannot shoot (we don't want the screen full of hundreds of beams (I don't think))

//Global utility integers
bool shootbeam;
int beamdelay;

global script slot_2{
    void run(){
    //power beam utility variables
    int beamd;
    int beamx;
    int beamy;
    lweapon beam1;
    lweapon beam2;
    int charging;
        while(true){
            //Power-beam script
            if(shootbeam){
                beamd = Link->Dir;
                beam1 = Screen->CreateLWeapon(8);
                beam1->UseSprite(Beam1ID);
                beam1->Damage = Beam1Damage;
                beam1->Step = BeamSpeed;
                beamx = 0; beamy = 0;
                if(beamd>1) beamx = (((beamd-2)*2)-1)*16;
                if(beamd<2) beamy = ((beamd*2)-1)*16;
                beam1->X = Link->X+beamx;
                beam1->Y = Link->Y+beamy;
                beam1->Z = Link->Z;
                beam1->Dir = beamd;
            Game->PlaySound(BeamSFX);
            Link->Action = LA_ATTACKING;
            shootbeam = false;
            beamdelay = BeamDelayMax;
            charing++;
            Waitframe();
                while((Link->InputA || Link->InputB) && charging < BeamChargeMax){
                    charging++;
                    beamd = Link->Dir;
                    Link->InputA = false;
                    Link->InputB = false;
                    Waitdraw();
                Link->Dir = beamd;
                Waitframe();
                }
                while((Link->InputA || Link->InputB) && charging >= BeamChargeMax){
                    beamd = Link->Dir;
                    Link->InputA = false;
                    Link->InputB = false;
                    Waitdraw();
                Link->Dir = beamd;
                Waitframe();
                }
                if(charging > BeamChargeMax){
                    beamd = Link->Dir;
                    beam2 = Screen->CreateLWeapon(8);
                    beam2->UseSprite(Beam2ID);
                    beam2->Damage = Beam2Damage;
                    beam2->Step = BeamSpeed;
                    beamx = 0; beamy = 0;
                    if(beamd>1) beamx = (((beamd-2)*2)-1)*16;
                    if(beamd<2) beamy = ((beamd*2)-1)*16;
                    beam2->X = Link->X+beamx;
                    beam2->Y = Link->Y+beamy;
                    beam2->Z = Link->Z;
                    beam2->Dir = beamd;
                Game->PlaySound(BeamSFX);
                Link->Action = LA_ATTACKING;
                }
            }
            if(beamdelay > 0) beamdelay--;        
            //Power-beam ends here

            //Other scripts go here...
            
        
        Waitframe();
        }
    }
}

//Activation script for the beam
item script Power_Beam{
    void run(){
        if(beamdelay == 0) shootbeam = true;
    }
}


Ok, I said 10 minutes, took me half an hour.
Make an item with that script attached as the activation script, and set the slot 2 global script to be that one.
Any other global scripts you're using will need to be copied into that script template, where I've noted.
Set up the inputs at the beginning how you need them; if there's anything that's unclear let me know and I'll sort it out for you.

#3 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 05:13 PM

Alright, when I attempted to compile, it said that the variables on lines 41, 44, an 77 were undeclared.

#4 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 05:15 PM

CODE
import "std.zh"

//Inputs
const int Beam1ID        = 0;    //Make a new weapon sprite with the un-charged power-beams'  data, and set its ID value here
const int Beam2ID        = 0;    //And the same for the charged power-beams' data here
const int BeamSFX        = 0;    //Sound effect to play when beam is fired

const int BeamSpeed        = 3;    //Speed for beams to fly at goes here
const int Beam1Damage    = 2;    //Damage for un-charged beam here
const int Beam2Damage    = 4;    //Damage for charged beam here
const int BeamChargeMax    = 20;    //Time to wait for beam to charge up here
const int BeamDelayMax    = 5;    //Delay in which Samus cannot shoot (we don't want the screen full of hundreds of beams (I don't think))

//Global utility integers
bool shootbeam;
int beamdelay;

global script slot_2{
    void run(){
    //power beam utility variables
    int beamd;
    int beamx;
    int beamy;
    lweapon beam1;
    lweapon beam2;
    int charging;
        while(true){
            //Power-beam script
            if(shootbeam){
                beamd = Link->Dir;
                beam1 = Screen->CreateLWeapon(8);
                beam1->UseSprite(Beam1ID);
                beam1->Damage = Beam1Damage;
                beam1->Step = BeamSpeed;
                beamx = 0; beamy = 0;
                if(beamd>1) beamx = (((beamd-2)*2)-1)*16;
                if(beamd<2) beamy = ((beamd*2)-1)*16;
                beam1->X = Link->X+beamx;
                beam1->Y = Link->Y+beamy;
                beam1->Z = Link->Z;
                beam1->Dir = beamd;
            Game->PlaySound(BeamSFX);
            Link->Action = LA_ATTACKING;
            shootbeam = false;
            beamdelay = BeamDelayMax;
            charging++;
            Waitframe();
                while((Link->InputA || Link->InputB) && charging < BeamChargeMax){
                    charging++;
                    beamd = Link->Dir;
                    Link->InputA = false;
                    Link->InputB = false;
                    Waitdraw();
                Link->Dir = beamd;
                Waitframe();
                }
                while((Link->InputA || Link->InputB) && charging >= BeamChargeMax){
                    beamd = Link->Dir;
                    Link->InputA = false;
                    Link->InputB = false;
                    Waitdraw();
                Link->Dir = beamd;
                Waitframe();
                }
                if(charging > BeamChargeMax){
                    beamd = Link->Dir;
                    beam2 = Screen->CreateLWeapon(8);
                    beam2->UseSprite(Beam2ID);
                    beam2->Damage = Beam2Damage;
                    beam2->Step = BeamSpeed;
                    beamx = 0; beamy = 0;
                    if(beamd>1) beamx = (((beamd-2)*2)-1)*16;
                    if(beamd<2) beamy = ((beamd*2)-1)*16;
                    beam2->X = Link->X+beamx;
                    beam2->Y = Link->Y+beamy;
                    beam2->Z = Link->Z;
                    beam2->Dir = beamd;
                Game->PlaySound(BeamSFX);
                Link->Action = LA_ATTACKING;
                }
            }
            if(beamdelay > 0) beamdelay--;        
            //Power-beam ends here

            //Other scripts go here...
            
        
        Waitframe();
        }
    }
}

//Activation script for the beam
item script Power_Beam{
    void run(){
        if(beamdelay == 0) shootbeam = true;
    }
}


Fixed.

#5 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 05:20 PM

OK, another attempt... now it says the following which I can't even make any sense out of.

PASS 4: Type-checking/completing function symbol tables/constant folding
TMP, line 32: Error T28: That pointer type does not have a function usesprite.AA

#6 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 05:22 PM

Ah right yeah.
That's a bit of a problem with the latest build.
You could either...

Go back to 842 (or previous) build, or...

Go into the 'std.zh' file in your ZC folder, and find the line that says:
CODE
const int WDS_NOHIT = -10;

And delete that line.

That'll fix it up.

#7 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 05:27 PM

Well, I'm using build 796...

the file doesn't contain that line so... maybe it's a problem with 796... I'll check with another build.

However, it DID work in 816.

#8 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 05:32 PM

Ohhhhh wait sorry.

Urmmmm....
Would you mind up-grading to Build 809 or higher?

I could change the script to work for builds before that one, but _L_ added in a function that takes about 20 lines of code out of that script just before build 809.


EDIT: Oh yeah, 816 should be fine.
Does it all work properly?

#9 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 05:48 PM

Alright, it's in and it works... however, it shoots every time the key is pressed... and when it is released, so you fire twice with one key stroke. Any way to fix that?

#10 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 05:49 PM

Oh =S

Well that's not very good.
Does the charging work?

I thought I'd fixed it so it wouldn't do that...
Hrm.

#11 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 05:59 PM

I might not have the weapon set up right...
CODE

const int Beam1ID        = 0;    //Make a new weapon sprite with the un-charged power-beams'  data, and set its ID value here
const int Beam2ID        = 0;    //And the same for the charged power-beams' data here
const int BeamSFX        = 0;    //Sound effect to play when beam is fired


Can you explain to me the setting up of the beam ID? I figured out the SFX thing, but not the ID.

#12 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 06:02 PM

Ah sorry urm...
Go to Quest->Graphics->Sprites->Weapons/Misc.
And make a new sprite with the graphic of the un-charged powerbeam, then put the ID number of that sprite for the first one.
Make another one with the graphic for the charged-up powerbeam, and put the ID number of that sprite for the second one.

Does the charging work?
If it doesn't, I'll get the script open in ZC and see to it myself (I haven't actually tested it yet)

#13 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 06:09 PM

OK, so I set it up...

The problem still lies in that it shoots when I release the key... which may make it so the charging doesn't work... because the charging isn't working.

#14 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 06:14 PM

Aha, ok.
In that case, the script doesn't work properly, so it's my fault =P

I'll fix it as soon as I can, but I don't know whether it's likely to be this evening or in 3 days time, because I'm going on holiday.
Rest assured that I will definately do it though.

Can you make do with this one till I get back?

#15 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 06:20 PM

Yeah, it'll be fine. Thanks for doing this for me.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users