Jump to content

Photo

Friendly Fire


  • Please log in to reply
16 replies to this topic

#1 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 27 May 2009 - 11:59 PM

Don't know if this requires a script or not, but that's the point of this request icon_razz.gif .
Basically, I want a script that allows enemy projectiles to hurt other enemies as well-for example, an Ocktoroc's projectile can hurt a Moblin, and vice-versa.
Thanks in advance to whoever does this.

#2 Joe123

Joe123

    Retired

  • Members

Posted 28 May 2009 - 04:11 AM

Are you sure you really want this?
The AI of Z1 enemies is pretty poor; they'll end up blasting each other to pieces I'dve thought.

#3 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 28 May 2009 - 06:11 AM

There are more than enough situations to warrant a script like this. Suppose you have fire-shooting statues that harm both Indiana Jones and the evil Nazis (YAY GODWIN'S LAW!!) that are invading the ancient temple.

#4 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 28 May 2009 - 08:13 AM

QUOTE(Joe123 @ May 28 2009, 02:11 AM) View Post
Are you sure you really want this?
The AI of Z1 enemies is pretty poor; they'll end up blasting each other to pieces I'dve thought.
Yes, I need this for cutscene purposes.

QUOTE(ShadowTiger @ May 28 2009, 04:11 AM) View Post
There are more than enough situations to warrant a script like this. Suppose you have fire-shooting statues that harm both Indiana Jones and the evil Nazis (YAY GODWIN'S LAW!!) that are invading the ancient temple.
As stated above.

#5 Joe123

Joe123

    Retired

  • Members

Posted 28 May 2009 - 08:52 AM

Shame we can't set an lweapon to an eweapon really, that'd make life easier.

You could try something like urrrrrr
CODE
for(int i=1;i<=Screen->NumEWeapons();i++){
    eweapon ew = Screen->LoadEWeapon(i);
    for(int j=1;j<=Screen->NumNPCs();j++){
        npc e = Screen->LoadNPC(j);
        if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->X = ew->X; l->Y = ew->Y;
        l->Damage = 2;
        l->DeadState = 6;
    }
}


Only problem is it'd probably keep hurting them while the eweapon is in contact with them.
Then again it might not though.

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 28 May 2009 - 08:58 PM

Yep thats basically it. (I've almost got this same bit of code in the starshooter game, so I just fixed it up a bit. just a dab here and theer and such, etc.)

CODE
for(int i=1;i<=Screen->NumEWeapons();i++)
{
    eweapon ew = Screen->LoadEWeapon(i);
    for(int j=1;j<=Screen->NumNPCs();j++)
    {
        npc e = Screen->LoadNPC(j);
        if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->X = ew->X; l->Y = ew->Y; l->Tile = ew->Tile;
        l->CSet = ew->CSet; l->Step = ew->Step; l->Dir = ew->Dir;
        if(ew->Angular){ l->Angular = true; l->Angle = ew->Angle; }
        l->Damage = ew->Damage/2;
        ew->DeadState = 0;
    }
}

Edited by Gleeok, 28 May 2009 - 08:59 PM.


#7 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 28 May 2009 - 09:12 PM

Heh. I dare you both to comment up your own scripts here. icon_blah.gif

#8 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 28 May 2009 - 10:04 PM

Oh, aaaaall rightie then. I suppose thats possible.




QUOTE(Gleeok @ May 28 2009, 06:58 PM) View Post



CODE
for(int i=1;i<=Screen->NumEWeapons();i++)

// start by cycling through all the enemy weapons on screen
{
    eweapon ew = Screen->LoadEWeapon(i); // we create a *gulp* pointer to them one by one

    // next we check each enemy weapon for a collision with an enemy

    for(int j=1;j<=Screen->NumNPCs();j++) //cycle through all of them too
    {
    // check each enemy for collision
        npc e = Screen->LoadNPC(j);
        if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;
    // no collision? continue the for loop. ..else we

    // do a weapon swap here. that is replace the eweapon with a lweapon (so as to hurt the enemy)

   // [ -actually for this it would be much easier to simply damage the enemy directly and kill the bullet, but really I'm not sure how that would be any better for darknuts, bosses. So it's probably better to let the built in zc collision code handle it. ]

        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->X = ew->X; l->Y = ew->Y; l->Tile = ew->Tile;
        l->CSet = ew->CSet; l->Step = ew->Step; l->Dir = ew->Dir;
        if(ew->Angular){ l->Angular = true; l->Angle = ew->Angle; }
        l->Damage = ew->Damage/2;
        ew->DeadState = 0; // kill the enemy weapon now that we don't need it anymore

    // so if we get to this line then we 1) had a collision with an enemy,  2) made the eweapon a lweapon, and 3) gave the lweapon the properties of the eweapon. got it?
    }
}




Does that help?

#9 Joe123

Joe123

    Retired

  • Members

Posted 29 May 2009 - 08:32 AM

CODE
//Run a loop which accesses the ID of each EWeapon on the screen
for(int i=1;i<=Screen->NumEWeapons();i++){

    //Create a pointer to the ith eweapon (so all of them)
    eweapon ew = Screen->LoadEWeapon(i);

    //The same, but for each npc
    for(int j=1;j<=Screen->NumNPCs();j++){
        npc e = Screen->LoadNPC(j);

        //Quick collision detection check. If the eweapon's not touching the enemy, 'continue' the loop so the rest doesn't run
        if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;

        //Create an lweapon to damage the enemy. We could just do e->HP -= damage, but it'd keep getting hurt while the weapon's on top of the enemy which isn't really what we want. Also wouldn't flash.
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);

        //Place the lweapon on top of where the eweapon is. Looking at this, it should actually be where the enemy is rather than where the eweapon is but whatever
        l->X = ew->X; l->Y = ew->Y;

        //Arbitrary amount of damage for it to deal
        l->Damage = 2;

        //Make sure it doesn't remain on the screen for more than 6 frames if it doesn't hit the enemy
        l->DeadState = 6;
    }
}


Now really, I should also be setting the lweapon's graphic to transparent and setting up a variable to stop lots of lweapons from keep spawning, but I'm lazy so I didn't.
I can add it if you want.

Mine's a bit different from Gleeok's because mine assumes the eweapon goes through the enemy and carries on going, although it still hurts it. Bit like the gold arrow or something.
Not quite sure why I decided it should do that, I just did.

QUOTE(Gleeok @ May 28 2009, 06:58 PM) View Post
// we create a *gulp* pointer to them one by one

Why the gulp?
Because it's probably not really a pointer?

I've been wondering whether there actually is any kind of pointer involved (well, obviously there is but not in the sense in which we would expect it to be a pointer), or whether it's just structured like that so it's more C-like.
I'm guessing it's not, from looking at the ASM interpreter.

#10 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 31 May 2009 - 11:45 AM

Uh...I'm using Joe's script and i'm getting this...
CODE
pass 1 : parsing
line 3 : syntax error, unexpected for, expecting $end, on token for
fatal error poo: can't open or parse imput file!


Just for the heck of it, here's the script as I imputted into ZQuest, version 1008:
CODE
import "std.zh"
//Run a loop which accesses the ID of each EWeapon on the screen
for(int i=1;i<=Screen->NumEWeapons();i++){

    //Create a pointer to the ith eweapon (so all of them)
    eweapon ew = Screen->LoadEWeapon(i);

    //The same, but for each npc
    for(int j=1;j<=Screen->NumNPCs();j++){
        npc e = Screen->LoadNPC(j);

        //Quick collision detection check. If the eweapon's not touching the enemy, 'continue' the loop so the rest doesn't run
        if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;

        //Create an lweapon to damage the enemy. We could just do e->HP -= damage, but it'd keep getting hurt while the weapon's on top of the enemy which isn't really what we want. Also wouldn't flash.
        lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);

        //Place the lweapon on top of where the eweapon is. Looking at this, it should actually be where the enemy is rather than where the eweapon is but whatever
        l->X = ew->X; l->Y = ew->Y;

        //Arbitrary amount of damage for it to deal
        l->Damage = 2;

        //Make sure it doesn't remain on the screen for more than 6 frames if it doesn't hit the enemy
        l->DeadState = 6;
    }
}
Am I doing anything wrong?


#11 Joe123

Joe123

    Retired

  • Members

Posted 31 May 2009 - 11:47 AM

Well, that might have something to do with the fact it isn't a script.
It's just a code-snippet.

Gleeok's ones better though, you should probably use his unless you particularily want the projectiles to go through the enemies?
I'll make the one you want into a script.

#12 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 31 May 2009 - 11:51 AM

I was hoping for the projectile to go away (for lack of a better term) after hitting the enemy.
Also, is there a way to set damage percentages to the projectile, or will all projectiles have a set damage value?

#13 Joe123

Joe123

    Retired

  • Members

Posted 31 May 2009 - 12:03 PM

What do you mean by 'damage percentages'?

CODE
ffc script FriendlyFire{
    void run(){
        while(true){
            for(int i=1;i<=Screen->NumEWeapons();i++){
                eweapon ew = Screen->LoadEWeapon(i);
                for(int j=1;j<=Screen->NumNPCs();j++){
                    npc e = Screen->LoadNPC(j);    
                    if(Abs(e->X-ew->X) > 8 || Abs(e->Y-ew->Y) > 8) continue;
                    lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
                    l->X = ew->X; l->Y = ew->Y; l->Tile = ew->Tile;
                    l->CSet = ew->CSet; l->Step = ew->Step; l->Dir = ew->Dir;
                    if(ew->Angular){ l->Angular = true; l->Angle = ew->Angle; }
                    l->Damage = ew->Damage/2;
                    ew->DeadState = WDS_DEAD;
                }
            }
        Waitframe();
        }
    }
}


#14 Silver

Silver

    If only scripting were that easy...

  • Members
  • Real Name:Silva
  • Location:Somewhere on this plane.

Posted 31 May 2009 - 01:56 PM

How much damage each projectile gives out. For example-it takes 2 hits from the Lv. 1 sword to kill a blue ocktorok, whereas with the Lv.2 sword it takes only one, therefore the Lv. 2 sword has twice the power of the Lv. 1 sword. Something like that.

EDIT: Um, what exactly does this script do? It seems to give me more health...it puts a counter on my hearts which decreases with every hit. O_O

#15 Joe123

Joe123

    Retired

  • Members

Posted 31 May 2009 - 02:05 PM

Yes, I understand the concept of 'damage' and 'percentages' ¬_¬
Could you explain how you want them to work a little better?

The script?
When an EWeapon gets right next to an enemy, it turns into an LWeapon so it can hurt the enemy.
Nothing to do with counters on your hearts, that's unrelated.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users