Jump to content

Photo

Some sort of generic boss request.


  • Please log in to reply
12 replies to this topic

#1 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 21 February 2009 - 10:21 PM

Since I suck with requesting in words, I made a picture to help:

IPB Image
I basically want a 2x2 enemy to start out in the cyan circle, and follow the arrows, stopping for a second or 2 when it hits the yellow circle areas. Also, while moving to the circle spots it should spit out 1 or 2 different damage combos.

I'd say that it should be easy but I'd probably be lying. :\

#2 Joe123

Joe123

    Retired

  • Members

Posted 22 February 2009 - 05:49 AM

What do you mean by 'spit out damage combos'?

#3 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 22 February 2009 - 11:39 AM

By that I mean that it should fire FFCs with damage combo properties at Link, instead of normal projectiles. I've seen it done before.

Though if that's too hard or you just can't be assed doing it, fireballs should be fine.

#4 Joe123

Joe123

    Retired

  • Members

Posted 22 February 2009 - 02:11 PM

Oh right.
What's wrong with a scripted weapon object?

What advantages does an ffc have?
The weapon can have any graphic and be larger than 16x16

#5 lucas92

lucas92

    Defender

  • Members

Posted 22 February 2009 - 06:19 PM

Also, you don't have to make hitbox with normal projectiles.

EDIT- I'm doing that script, just letting you know. icon_wink.gif

EDIT2- I have the movement working right for now:

EDIT3- I've got the projectiles now.

CODE
import "std.zh"

//
//Boss for Lithium but also could be used by others.;)
//By Lucas92
//

//Set its HP with the enemy editor and set the ffc data with the freeform combo editor


//the boss constants
const int BOSS_DAMAGE = 4; //Quarters hearts

//The resting time in frames 60 frames = 1 second
const int TIME = 30;

//The attacking intervall in frames 60 frames = 1 second
const int TIME2 = 30;

//the X positions
//                  2
//        1                    3
//                  2
const int X1 = 56;
const int X2 = 100;
const int X3 = 192;

//the Y positions
//               1
//     2                 2
//               3
const int Y1 = 10;
const int Y2 = 40;
const int Y3 = 90;

//Projectiles variable
const int PROJECTILE_SPEED = 2;
const int PROJECTILE_DAMAGE = 2;
const int PROJECTILE_SOUND = 13;

// Method to move a FFC angularly based on a target location
// and speed without constant supervision
// By LinktheMaster

// Parameters
// ffc combo - The FFC to be moved
// int targetX - The target X location
// int targetY - The target Y location
// int speed - The total FFC movement speed

void angularMove(ffc combo, int targetX, int targetY, int speed)
{

  // Calculate the distance to the target location
  int xDis = targetX - combo->X;
  int yDis = targetY - combo->Y;
  int dis = Abs(xDis) + Abs(yDis);

  // Calculate the speed coefficient
  float d = speed / dis;

  // Calculate the speeds for each direction
  combo->Vx = d * xDis;
  combo->Vy = d * yDis;
} // End of angularMove

//D0 : The number of the FFC in the list
//D1 : The number of the NPC in the enemy list
//D2 : The speed of the boss
ffc script BOSS
{
    void run(int FFC, int NPC,int speed)
    {
        Waitframes(4);
        
        ffc boss = Screen->LoadFFC(FFC);
        npc ghosted = Screen->LoadNPC(NPC);
        
        //ghosted declarations
        ghosted->Extend = 3;
        ghosted->TileWidth = 2;
        ghosted->TileHeight = 2;
        
        //Hitbox in pixels
        ghosted->HitWidth = 32;
        ghosted->HitHeight = 32;
        ghosted->Damage = BOSS_DAMAGE;
        
        //Initializing position
        boss->X = X2;
        boss->Y = Y1;
        
        ghosted->X = boss->X;
        ghosted->Y = boss->Y;
        
        //Position variable
        bool position[4];
        
        //Initializing the array
        position[1] = true;
        position[2] = false;
        position[4] = false;
        
        //Resting time variable initialization
        int counter = TIME;
        int counter2 = TIME2;
        int fireball = 0;
        
        while(true)
        {
            //Moving routine
            counter -= 1;
            counter2 -= 1;
            if(position[1])
            {
                if(counter <= 0)
                {
                    angularMove(boss, X3, Y2, speed);
                    if(boss->X >= X3)
                    {
                        boss->Vx = 0;
                        boss->Vy = 0;
                        boss->X = X3;
                        boss->Y = Y2;
                        position[1] = false;
                        position[2] = true;
                        counter = TIME;
                    }
                }
            }
            if(position[2])
            {
                if(counter <= 0)
                {
                    angularMove(boss, X2, Y3, speed);
                    if(boss->X <= X2)
                    {
                        boss->Vx = 0;
                        boss->Vy = 0;
                        boss->X = X2;
                        boss->Y = Y3;
                        position[2] = false;
                        counter = TIME;
                    }
                }
            }
            if(!position[2]&&!position[1]&&!position[4])
            {
                if(counter <= 0)
                {
                    angularMove(boss, X1, Y2, speed);
                    if(boss->X <= X1)
                    {
                        boss->Vx = 0;
                        boss->Vy = 0;
                        boss->X = X1;
                        boss->Y = Y2;
                        position[4] = true;
                        counter = TIME;
                    }
                }
            }
            if(position[4])
            {
                if(counter <= 0)
                {
                    angularMove(boss, X2, Y1, speed);
                    if(boss->X >= X2)
                    {
                        boss->Vx = 0;
                        boss->Vy = 0;
                        boss->X = X2;
                        boss->Y = Y1;
                        position[1] = true;
                        position[4] = false;
                        counter = TIME;
                    }
                }
            }
            if(!ghosted->isValid())
            {
                boss->Data = 0;
                break;
            }
            if(counter2 <= 0)
            {
                Game->PlaySound(PROJECTILE_SOUND);
                HomingFireball(Link->X, Link->Y, boss->X+16 , boss->Y+16);
                counter2 = TIME2;
            }
            ghosted->X = boss->X;
            ghosted->Y = boss->Y;
            Waitframe();
        }
    }
    //
    //Thanks go to Gleeok on that one.
    //void HomingFireball
    void HomingFireball(int lx, int ly, int tx, int ty)
    {
        eweapon fireball;
        fireball = Screen->CreateEWeapon(EW_FIREBALL);
        fireball->HitWidth=16;fireball->HitHeight=16;
        fireball->X=tx;fireball->Y=ty;fireball->Step= PROJECTILE_SPEED*100;fireball->Damage=PROJECTILE_DAMAGE;
        fireball->Angular=true;fireball->Angle = ArcTan(lx-tx,ly-ty);
    }
}


Just have to decide on what weapons he should trow.

Edited by lucas92, 02 March 2009 - 09:10 AM.


#6 lucas92

lucas92

    Defender

  • Members

Posted 28 February 2009 - 06:47 PM

Well, I've updated the script but I don't really know how to create a fireball each time that "counter2==0" at an another position than (0,0).

Ideally it would be (boss->X+16, boss->Y+16)...

Anyone has an idea on how to do it? icon_eek.gif

#7 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 01 March 2009 - 01:35 AM

QUOTE(lucas92 @ Feb 28 2009, 03:47 PM) View Post

Well, I've updated the script but I don't really know how to create a fireball each time that "counter2==0" at an another position than (0,0).

Ideally it would be (boss->X+16, boss->Y+16)...

Anyone has an idea on how to do it? icon_eek.gif


this should do it:

CODE
for(i; i<max; i++){
eweapon e;
e->X = x; e->Y = y;
e->Angular = true;
e->Angle = angle;
}


where angle is in radians:
angle = ArcTan(lx-x,ly-y)*(PI/180); - (*homing)
or angle = RadianCos(n); would do it if you like. I prefer degrees though, so to convert just multiply the radian number by 0.01745. It's accurate enough.

Hope that helps.

Edited by Gleeok, 01 March 2009 - 01:40 AM.


#8 lucas92

lucas92

    Defender

  • Members

Posted 01 March 2009 - 08:54 AM

-(*homing) ?

What is homing?

Do I place that code in the main loop or in the "counter2 <= 0" condition? icon_confused.gif

#9 Joe123

Joe123

    Retired

  • Members

Posted 01 March 2009 - 03:02 PM

The value pointed by homing?

It seems Gleeok has managed to implement pointers into ZScript.

#10 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 01 March 2009 - 07:16 PM

No sorry, I just meant that that's how you find the angle from one point to another: using ArcTan(x,y); (Hence the Homing)
Also I made a mistake in my previous post, ArcTan automatically returns a radian value so there's no need to convert it. It was late when I wrote it and sorry about that, hope this clarifies it.

Here's some random bullet code pulled from Grikarugun so you can see an example of what I was referring to.

CODE
    laser = Screen->CreateEWeapon(EW_MAGIC);
    laser->HitWidth=4;laser->HitHeight=4;laser->HitXOffset=6;laser->HitYOffset=6;
    laser->X=tx+32;laser->Y=ty;laser->Step=200;laser->Damage=2;laser->CSet=1;
    laser->Angular=true;laser->Angle = arc1-((bullet_count+2)/10);

CODE

                        if(GAME_MODE>=HARD)cheat=10;
                        else cheat = 20;

                        laser = Screen->CreateEWeapon(EW_MAGIC);
                        laser->HitWidth=6;laser->HitHeight=6;laser->HitXOffset=5;laser->HitYOffset=5;
                        laser->X=tx-32;laser->Y=ty-8;laser->Step=200;laser->Damage=2;
                        laser->CSet=1;laser->Tile=1600;
                        laser->Angular=true;laser->Angle = ArcTan(lx-(tx-32),ly-(ty-8));



CODE
void B_HomingShot(int lx, int ly, int tx, int ty){

    eweapon laser;
    laser = Screen->CreateEWeapon(EW_MAGIC);
    laser->HitWidth=4;laser->HitHeight=4;laser->HitXOffset=6;laser->HitYOffset=6;
    laser->X=tx;laser->Y=ty;laser->Step=200;laser->Damage=2;laser->CSet=0;
    laser->Angular=true;laser->Angle = ArcTan(lx-tx,ly-ty);
}



QUOTE(Joe123 @ Mar 1 2009, 12:02 PM) View Post

The value pointed by homing?

It seems Gleeok has managed to implement pointers into ZScript.


bool Smartass(dev &joe123) throw()
{
return true;
}

In yer fayc! :-P

PS: Everyone knows this is a pointer: "->"

Edited by Gleeok, 01 March 2009 - 07:16 PM.


#11 lucas92

lucas92

    Defender

  • Members

Posted 02 March 2009 - 09:12 AM

Hey thanks for that one Gleeok. icon_smile.gif

I've updated the boss script so I think it would be the final one.

#12 lucas92

lucas92

    Defender

  • Members

Posted 02 March 2009 - 09:14 AM

EDIT-Lagging. Sorry.

Edited by lucas92, 02 March 2009 - 09:14 AM.


#13 Joe123

Joe123

    Retired

  • Members

Posted 02 March 2009 - 10:24 AM

QUOTE(Gleeok @ Mar 2 2009, 12:16 AM) View Post
PS: Everyone knows this is a pointer: "->"


icon_redface.gif
It does look like an arrow *grumbles*


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users