Jump to content

Photo

make an enemy blink for taking damage


  • Please log in to reply
16 replies to this topic

#1 Alestance

Alestance

    Saint Alestance - Eliminator of the ZGP format

  • Members
  • Real Name:Lonk
  • Location:Pennsylvania

Posted 20 January 2008 - 12:26 PM

Me and just about everyone and their mother are looking for a script that will make enemies blink when they take damage. It should be global. Remember this is designed for 8-bit tilesets and will be completely useless to anyone that use default tiles for enemy sprites.

alternatively, I came up with this as a bit of a guide

If Enemy1 health < Enemy1Loaded Health
Set Drawstyle to Phantom
Wait 10 frames
Set Drawstyle to Normal
Load Enemy1 health to Enemy1Loaded Health
waitframe
endif

I'm not familiar with Zscript's options so I'm not sure. Secondly this should be a Global Script.

I'm also not sure how easy it will be, but by what I made, it shouldn't be hard.

Good luck.

#2 Joe123

Joe123

    Retired

  • Members

Posted 20 January 2008 - 01:37 PM

If Enemy1 health < Enemy1Loaded Health
Set Drawstyle to Phantom
Wait 10 frames
Set Drawstyle to Normal
Load Enemy1 health to Enemy1Loaded Health
waitframe
endif

Well, you won't get much function out of that, especially as the global script.
Waiting for 10 frames in the global script is lethal; will mess up all of your other functions, plus stopping all other enemies from 'blinking' for 10 frames.
You could still do that though, it'd just require a little integer manipulation and pseudo for loops using ifs, which is by no means complex.

The main problem, though, is that you can't just 'set drawstyle to phantom';
CODE
int DrawStyle
* The way the NPC is animated. Use the DS_ constants in std.zh to set or
* compare this value. [b]The effect of writing to this field is currently undefined.[/b]


What you could, perhaps, do, would be to set the NPC's coords into an integer, then move it to, say, (-16,-16) and back again on and off for 10 frames.

However, doing it that way still wouldn't work as the global script, as the enemy list wouldn't refresh every time you changed screens, so you'd have to have it as an ffc script on every single screen where you wanted enemies.

What you might be able to do with the global script could be something like:

CODE
int screennumber;
int dmapnumber;
int e1hp; int e1timer; int x1; int y1;
//...
int e10hp; int e10timer; int x10; int y10;
while(true)
    if(screennumber != current screen coorinate || dmap number != current dmap number){
        //run a for loop that will load all screen's enemies
    }

    if(e1hp < first enemy's health){e1timer = 10; x1 = e1->X; y1 = e1->Y;}
    
    if(e1timer > 0){
        if(e1timer == even){ e1->X = -16; e1->Y = -16;}
        if(e1timer == odd || e1timer == 0){ e1->X = x1; e1->Y = y1;}
    }
    //and repeat for e2-e10


    if(there is actually an npc1 on the screen) e1hp = e1->hp;
    //...
    if(there is actually an npc10 on the screen) e1hp = e1->hp;

    screen number = the current screen coordinate in the dmap;
    dmap number = the current dmap number;

Waitframe();
}


Quite horrendous to write, and checking npc's health every frame isn't too fun either.

Obviously that script wouldn't work, it's just a bit of a template.

Oh yeah, and arrays would make the job significantly less complex too.
Shame we don't have them really.

Edited by Joe123, 20 January 2008 - 01:38 PM.


#3 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 22 January 2008 - 05:23 AM

If you punch someone in the face do they flash colors?

















....
..
....
What would be infinitely less hassle would be an ffc or drawtile's to appear over a damaged enemy. Still CPU intensive though.

#4 Joe123

Joe123

    Retired

  • Members

Posted 22 January 2008 - 11:19 AM

icon_eyebrow.gif
But that'd mean just having a blob appear over your enemies.

It'd be crappy...

#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 22 January 2008 - 05:53 PM

Well I was thinking a quick animation that cycles back to combo 1...But if a sprite uses all csets how are you supposed to switch between them without ->Flash or Drawstyle?

#6 Joe123

Joe123

    Retired

  • Members

Posted 22 January 2008 - 06:02 PM

Make them blink like A) was asked and B) I explained icon_confused2.gif

#7 Snarwin

Snarwin

    Still Lazy After All These Years

  • Members
  • Real Name:Paul
  • Location:New York

Posted 22 January 2008 - 10:40 PM

QUOTE
But if a sprite uses all csets how are you supposed to switch between them without ->Flash or Drawstyle?
Couldn't you just do something like

enemy->cset += 1;

Might not look quite as pretty, but I don't see any reason it wouldn't work.

#8 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 22 January 2008 - 10:53 PM

That's what I was saying; 8-bit mode uses all csets, so if you change what cset the sprite uses it will remain the same color.

#9 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 23 January 2008 - 12:14 AM

Here's my question: Do you really need enemies to be in 8 bit mode? But, as far as I can see, there really isn't a way to make it flash with a script.

#10 Joe123

Joe123

    Retired

  • Members

Posted 23 January 2008 - 02:43 AM

Well you could make it flash with a script, if all of your enemies where invisible (as in, had no tile), and then the script made them 'visible' by placing an ffc over them, then changing it when he took damage.

It's possible, just stupid.

Anyway, he asked for it to blink, not flash...

#11 Radien

Radien

    Courage

  • Members
  • Real Name:Steve
  • Location:Oregon

Posted 23 January 2008 - 04:35 AM

People are clamoring for this? I'M NOT ALONE. icon_biggrin.gif

It'd be nice if they'd just up and added it to the next version of ZC. But with the suggestions forum closed until further notice, I think it's safe to say that we can't count on it and it's worth scripting.

I quite hope you folks can manage to work it out. If you can, I'm all ears. (once the new stable version of ZC comes out, that is...)

#12 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 23 January 2008 - 04:56 AM

Well, 2.5 isn't really set up to make this easy. What you are going for Joe, is setting a loop every frame of gameplay to check if an enemy is damaged or not:

Simulating knockback via integers and walkability functions, and moving an enemy so it appears to 'blink' because you can't simply flash it's cset. This probably will result in buggy behavior from jumping enemies and as we should know by now, will cause leever type enemies to move through walls and leave the screen. Not to mention moldorms, lanmola's, bosses and void warranty on some other enemy scripts. I hope the random crashes have been fixed also, especially from global scripts that can't "reset" on screen init...those love to crash zc.

Sounds more suited for a 2.6 suggestion, but that doesn't mean it isn't possible though.



..well alright. Here's my suggestion that might do something;


//check hp
//if damaged{
t = npc->Tile;
//check drawstyle, set an array based on this.
npc->Tile += result; //every enemy needs a flashing setup in the tile page icon_frown.gif
//set back to original
npc->Tile = t;
etc...


Good luck.

Edited by Gleeok, 23 January 2008 - 05:05 AM.


#13 Alestance

Alestance

    Saint Alestance - Eliminator of the ZGP format

  • Members
  • Real Name:Lonk
  • Location:Pennsylvania

Posted 23 January 2008 - 05:42 AM

QUOTE(Gleeok @ Jan 22 2008, 05:23 AM) View Post

If you punch someone in the face do they flash colors?


Hey, that was MINE when *I* was making a comment about an 8 bit tileset icon_razz.gif

and as for the script: So long as people have something to flag that an enemy has taken damage, as that is the biggest concern with 8-bit tiles.

Edited by Master_of_Power, 23 January 2008 - 05:42 AM.


#14 Joe123

Joe123

    Retired

  • Members

Posted 23 January 2008 - 10:52 AM

Oh, I thought NPC->Tile was broken?


And the SFX playing is enough for me personally...

Edited by Joe123, 23 January 2008 - 10:52 AM.


#15 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 23 January 2008 - 11:24 AM

QUOTE(Joe123 @ Jan 23 2008, 07:52 AM) View Post

And the SFX playing is enough for me personally...

Same here. Does the enemy really need to flash. It seems - unnatural.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users