make an enemy blink for taking damage
#1
Posted 20 January 2008 - 12:26 PM
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
Posted 20 January 2008 - 01:37 PM
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';
* 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:
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
Posted 22 January 2008 - 05:23 AM
....
..
....
What would be infinitely less hassle would be an ffc or drawtile's to appear over a damaged enemy. Still CPU intensive though.
#4
Posted 22 January 2008 - 11:19 AM
But that'd mean just having a blob appear over your enemies.
It'd be crappy...
#5
Posted 22 January 2008 - 05:53 PM
#6
Posted 22 January 2008 - 06:02 PM
#7
Posted 22 January 2008 - 10:40 PM
enemy->cset += 1;
Might not look quite as pretty, but I don't see any reason it wouldn't work.
#8
Posted 22 January 2008 - 10:53 PM
#9
Posted 23 January 2008 - 12:14 AM
#10
Posted 23 January 2008 - 02:43 AM
It's possible, just stupid.
Anyway, he asked for it to blink, not flash...
#11
Posted 23 January 2008 - 04:35 AM
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
Posted 23 January 2008 - 04:56 AM
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
//set back to original
npc->Tile = t;
etc...
Good luck.
Edited by Gleeok, 23 January 2008 - 05:05 AM.
#13
Posted 23 January 2008 - 05:42 AM
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
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
Posted 23 January 2008 - 10:52 AM
And the SFX playing is enough for me personally...
Edited by Joe123, 23 January 2008 - 10:52 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users