Jump to content

Photo

Samus' Power Beam


  • Please log in to reply
37 replies to this topic

#16 Joe123

Joe123

    Retired

  • Members

Posted 16 August 2008 - 06:24 PM

That's fine, it's pretty simple and I'm finding it quite entertaining.

I'll get back to you in a couple days...

...and with that, I'm off to bed.


#17 Colin

Colin

    Coblin the Goblin

  • Members

Posted 16 August 2008 - 07:06 PM

Alright, I'll list all of the current bugs/problems with the script now, so when you get back, they can get fixed.

1: Gun fires when key is both pressed, and released.
2: When the fire button is being held down, Samus may only move the current direction she is facing.
3: The actual shot starts 16 pixels away from the Samus sprite
4: The charging doesn't work.

EDIT: That was weird.

When I first start up the game, the press and release fire thing, doesn't happen for the first 4 shots or so... then it starts to be buggy...

#18 Joe123

Joe123

    Retired

  • Members

Posted 17 August 2008 - 02:57 AM

QUOTE(Nuvo @ Aug 17 2008, 01:06 AM) View Post
2: When the fire button is being held down, Samus may only move the current direction she is facing.
3: The actual shot starts 16 pixels away from the Samus sprite


Those are intentional, I thought they were quite nice....
Did you want the shot to start on top of Samus?
I always thought that looked horrible...

#19 Colin

Colin

    Coblin the Goblin

  • Members

Posted 17 August 2008 - 08:09 AM

Um... maybe not on top of Samus, but maybe something only like 4 pixels-8 pixels away.

Maybe as soon as the charging works, that I'll like Samus' inability to move in any special direction while charging.

Also, I wonder if there's a script that can decrease enemy daze time, to like a quarter to a half of what it is... that would make this beam so much more useful.

I'm not asking you to make it... well, I am... but you don't have to do it if it's complex or whatever... well, you don't have to do it period. But it would really help.

#20 TetriTek

TetriTek

    Wizard

  • Members
  • Real Name:Joshua Johnson
  • Location:Clinton

Posted 18 August 2008 - 04:20 PM

Hey Joe, wouldn't the problem with the releasing be that that's how you fire the charge shot, you just haven't set a variable saying its been charged all the way? I don't script in ZC, as its never worked, but I do other kind of scripting.

#21 Joe123

Joe123

    Retired

  • Members

Posted 19 August 2008 - 01:46 PM

Ohhhh, wait a second here!
When you said 'Samus can only move in one direction while charging', I read it as 'Samus can only face in one direction while charging'.
You're meant to be able to move in all four directions, just only face in one direction.
Oops.


And after trying out this script, it's a complete mess.
So I think I'm going to start over.
This is what happens when I try to code something over-complicated from scratch without even testing it >_<


And I'm afraid that enemy script isn't really feasable, although I'd be happy to look into any other scripts you wanted.

Hopefully I'll be able to get this one sorted within the next couple hours.

EDIT:
Ah, only took me 35 mins too =)
It wasn't as bad as I thought, I'd just forgotten to reset a variable.
Similar to what you said P_C, but not quite.
Thanks anyway though.

So, here we go:
CODE
import "std.zh"

//Inputs
const int Beam1Tile        = 0;    //Tile for the un-charged beam to use
const int Beam1Frames    = 0;    //No. frames of animation
const int Beam1Speed    = 0;    //Speed
const int Beam2Tile        = 0;    //Tile for charged beam to use
const int Beam2Frames    = 0;    //No. frames of animation
const int Beam2Speed    = 0;    //Speed
const int BeamCset        = 8;    //Cset for the beams to use

const int BeamChargeSFX    = 35;    //Sound effect to play when beam is fully-charged
const int BeamSFX        = 2;    //Sound effect to play when beam is fired

const int NoTurn        = 1;    //If greater than 0, Samus cannot turn to face a different direction whilst charging up the beam. If set to 0, she can turn around. This only works with Diagonal Movement on.
const int DistFromSprite= 8;    //The number of pixels away from Samus the projectile is fired from. Default 8, set it up how you will.
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    = 40;    //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->OriginalTile = Beam1Tile;
                beam1->Tile = Beam1Tile;
                beam1->CSet = BeamCset;
                beam1->NumFrames = Beam1Frames;
                beam1->ASpeed = Beam1Speed;
                
                beam1->Damage = Beam1Damage;
                beam1->Step = BeamSpeed;
                beamx = 0; beamy = 0;
                if(beamd>1) beamx = (((beamd-2)*2)-1)*DistFromSprite;
                if(beamd<2) beamy = ((beamd*2)-1)*DistFromSprite;
                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++;
            beamd = Link->Dir;
            Waitframe();
                while((Link->InputA || Link->InputB) && charging < BeamChargeMax){
                    charging++;
                    Link->InputA = false;
                    Link->InputB = false;
                    if(NoTurn > 0){
                        Waitdraw();
                    Link->Dir = beamd;
                    }
                Waitframe();
                }
                if(charging >= BeamChargeMax) Game->PlaySound(BeamChargeSFX);
                while((Link->InputA || Link->InputB) && charging >= BeamChargeMax){
                    Link->InputA = false;
                    Link->InputB = false;
                    if(NoTurn > 0){
                        Waitdraw();
                    Link->Dir = beamd;
                    }
                Waitframe();
                }
                if(charging >= BeamChargeMax){
                    beamd = Link->Dir;
                    beam2 = Screen->CreateLWeapon(8);
                    beam2->OriginalTile = Beam2Tile;
                    beam2->Tile = Beam2Tile;
                    beam2->CSet = BeamCset;
                    beam2->NumFrames = Beam2Frames;
                    beam2->ASpeed = Beam2Speed;
                    
                    beam2->Damage = Beam2Damage;
                    beam2->Step = BeamSpeed;
                    beamx = 0; beamy = 0;
                    if(beamd>1) beamx = (((beamd-2)*2)-1)*DistFromSprite;
                    if(beamd<2) beamy = ((beamd*2)-1)*DistFromSprite;
                    beam2->X = Link->X+beamx;
                    beam2->Y = Link->Y+beamy;
                    beam2->Z = Link->Z;
                    beam2->Dir = beamd;
                Game->PlaySound(BeamSFX);
                Link->Action = LA_ATTACKING;
                }
            charging = 0;
            }
            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;
    }
}

Replace your old script with this one, and it should all work fine and dandy =)

The set up is a bit different though, it no longer uses a weapon sprite (I couldn't get that to work), so you have to input a bit more information at the top.
This should be pretty much self-explanitory.

Currently it's set up for a projectile that looks the same regardless of direction (so a circle or something), and wouldn't work with a line or similar.
This is intentional, and if you want it changed to work with a projectile that does change depending on which direction it's facing, let me know and I'll fix it up.

I've also changed it so that you can decide how far away from Samus the projectile is fired from, which is now an input at the beginning.
Do with that as you wish, 8 seemed good to me.

The last thing is to do with the 'can only move in one direction whilst charging'.
This does work how I set it up before, it's just that you have to use Diagonal Movement.
Now, I understand that you might not want to for one reason or another, so I've included a little input at the beginning.
If you do decide to change to diagonal movement, just leave the input as it is.
If you want to keep it on the old-style movement, change that input to 0, and Samus will be able to turn whilst charging.
Sorry, it just doesn't seem to want to work with 4-way movement.

#22 Colin

Colin

    Coblin the Goblin

  • Members

Posted 19 August 2008 - 09:25 PM

Alright! It works like a charm...

Would it be possible to add two more features? Just to add a sense of completeness.

1: Make it so Samus will flash while charging.
2: Make it so there is a sound effect while charging.

EDIT: Actually, scrap number 1.

#23 Joe123

Joe123

    Retired

  • Members

Posted 20 August 2008 - 04:51 AM

I could make Samus flash if you like, but you'd have to sacrifice one of the rings.
If you only used the blue and red ring in the quest, I could use the gold ring to make Samus flash.

And could you be a bit more specific about the sound effect?
I've put that one in so that it plays a sound effect when the beam first becomes charged, did you want another one too?

#24 Colin

Colin

    Coblin the Goblin

  • Members

Posted 20 August 2008 - 12:10 PM

I wanted a sound effect of WHILE charging. The current sound effect is WHEN it's charged. I want both though.

#25 Joe123

Joe123

    Retired

  • Members

Posted 20 August 2008 - 01:12 PM

Ah right.
So something that loops?
Or just one sound effect that lasts for that length of time?

#26 Colin

Colin

    Coblin the Goblin

  • Members

Posted 20 August 2008 - 02:44 PM

Length of time, I have a bunch of metroid sound effects, so I think I'm good on that part.

#27 Joe123

Joe123

    Retired

  • Members

Posted 20 August 2008 - 06:07 PM

Ah, the only problem with doing that would be if you were to start charging up the power beam, then release the button and not let it fully charge.
There's no way of stopping a sound effect once it's started playing, so even though Samus' beam isn't being charged to full, it'd sound like it was.
If you get me?

#28 Colin

Colin

    Coblin the Goblin

  • Members

Posted 20 August 2008 - 06:48 PM

ah, that makes sense. OK, then do a repeated one then.

#29 TetriTek

TetriTek

    Wizard

  • Members
  • Real Name:Joshua Johnson
  • Location:Clinton

Posted 20 August 2008 - 10:18 PM

Why can't you stop the sound effect? I thought you could... thats weird, I must be thinking of something else. So there is no way you can?

#30 Joe123

Joe123

    Retired

  • Members

Posted 21 August 2008 - 04:38 AM

No, it's impossible.


Dyuknow how long your sound effect is in frames?
That's quite important.

One frame is 1/60th of a second.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users