Jump to content

Photo

Enemy status effect GFX


  • Please log in to reply
8 replies to this topic

#1 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 03 June 2019 - 03:50 PM

Hey,

 

I had an idea: what if when an enemy is f.e. stunned by a boomerang it is actually visible? As in, the sprite of the enemy changes. Just imagine an enemy being on fire after being hit by a candle!

 

But I highly doubt it's possible in an easy way.

 

I'd like to ask you guys for ideas. Could you please think of a way I could preferably layer the "status effect" over the enemy?

 

The scripting is something I'm willing to attempt myself. :-)



#2 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 03 June 2019 - 04:01 PM

You could create a combo which represents each status effect (combo so it can have whatever animation).

Then, in a global script, loop through each NPC, and use DrawCombo (or FastCombo) to draw it at a position above the enemy.

If you have a custom status effect system, you would simply check for each status, and draw the combo if the status is present.

 

As for script setup, I'd probably create a function for the status drawing; something like this

const int COMBO_STUNNED = 0;
const int CSET_STUNNED = 0;
const int STATUSFX_LAYER = 5;
void drawStatus(npc n)
{
    if(n->Stun)
    {
        Screen->FastCombo(STATUSFX_LAYER, n->X, n->Y-8, COMBO_STUNNED, CSET_STUNNED, OP_OPAQUE);
    }
    //Add other `if` checks for other statuses here
}

Then to loop, do

for(int q = 1; q <= Screen->NumNPCs(); ++q)
{
    npc n = Screen->LoadNPC(q);
    drawStatus(n);
    //Anything else you need to do globally for every NPC can be done here
}

Or, in 2.55, you could call it as part of an npc script instead of using a global loop. For any existing NPC script, you'd need to add `drawStatus(this)` calls- for any npcs without scripts, you'd need to give them a script which calls `drawStatus` each frame.

 

(Note: script thrown together quickly and not compile-tested, may contain typos)


  • ShadowTiger and Twilight Knight like this

#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 04 June 2019 - 06:20 AM

You are better-off writing to o_tile.


  • Twilight Knight likes this

#4 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 04 June 2019 - 06:38 AM

You are better-off writing to o_tile.

...HOW WOULD THAT HELP?

You're saying then to create a stunned version of EVERY ENEMY SPRITE?

I'm pretty sure the idea here was like, spinning stars above their head- which NOT work with modifying the npc's tile...


  • Twilight Knight likes this

#5 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 04 June 2019 - 12:45 PM

Thanks a lot Venrob, something like that is indeed what I intend to achieve.

 

I'm indeed using ZC2.55, so I'll be using the NPC script. That is a nice new feature. :-)

 

Now only to problem of giving the enemy the "status effect" arises. Are there ways to detect if an enemy has been hit by let's say a boomerang? I'm hoping I can simply have a condition in an if statement in the same NPC script that triggers the drawStatusEffect() function if true. I hardly know anything about the scripting possibilities nowadays.  :heh:

 

 

If I manage to make the script I intend to release it to the database, with credits due of course.



#6 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 04 June 2019 - 01:29 PM

Thanks a lot Venrob, something like that is indeed what I intend to achieve.

 

I'm indeed using ZC2.55, so I'll be using the NPC script. That is a nice new feature. :-)

 

Now only to problem of giving the enemy the "status effect" arises. Are there ways to detect if an enemy has been hit by let's say a boomerang? I'm hoping I can simply have a condition in an if statement in the same NPC script that triggers the drawStatusEffect() function if true. I hardly know anything about the scripting possibilities nowadays.  :heh:

 

 

If I manage to make the script I intend to release it to the database, with credits due of course.

In my script there I used `npc->Stun`, which will detect the boomerang having stunned it. As for other effects, you'd need a custom effects system of some kind, and there is no simple "best way" to do that, so that's more up to you.

 

You don't want to call the `drawStatus` only if they have a status though; you check if they have the status IN drawStatus.

 

As for NPC scripts, you'd want to add the drawStatus call to any existing npc scripts as `drawStatus(this)`- and any enemies without scripts, you probably want a generic script containing things for all enemies. In fact, you may want to make a generic enemy handling function- here, I can do that quick.

npc script generic
{
    while(true)
    {
        handleNPC(this);
        Waitframe();
    }
}

void handleNPC(npc n)
{
    //Put anything that needs to happen for every NPC every frame here
    drawStatus(n);
}

Then, you can assign that script to any non-scripted enemies, and call `handleNPC(this)` in any other npc scripts you have. This will let you run any kind of check there that needs to run for every enemy.


  • Twilight Knight likes this

#7 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 04 June 2019 - 02:27 PM

Aha, thanks, for some reason I missed the npc->Stun part.

 

And having this kind of setup makes a lot more sense indeed.

 

Is there a way to detect which kind of item has hit an enemy? So f.e. fire from a candle?

 

I see this in the documentation:

bool CollDetection;		ZASM Instruction: 
					NPCCOLLDET
	/**
	* Whether the NPC will use the system's code to work out collisions with Link
	* Initialised as 'true'.
	*/

Can this be used to detect the kind of weapon that hit the enemy?

 

If not, at least I can do something with the stun, so thank you :-)



#8 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 04 June 2019 - 02:31 PM

Aha, thanks, for some reason I missed the npc->Stun part.

 

And having this kind of setup makes a lot more sense indeed.

 

Is there a way to detect which kind of item has hit an enemy? So f.e. fire from a candle?

 

I see this in the documentation:

bool CollDetection;		ZASM Instruction: 
					NPCCOLLDET
	/**
	* Whether the NPC will use the system's code to work out collisions with Link
	* Initialised as 'true'.
	*/

Can this be used to detect the kind of weapon that hit the enemy?

 

If not, at least I can do something with the stun, so thank you :-)

That most certainly cannot be used to detect what hit an enemy. That is a boolean (i.e. true or false) of if the enemy has collision detection (i.e. are they invincible)

As for detecting what has hit an enemy, 2.55 has a new thing `HitBy[]`, though I'm unsure if it's finished/working; Zoria would be the one to talk to about that


  • Twilight Knight likes this

#9 Twilight Knight

Twilight Knight

    Tell all with glee, Argon's on PureZC

  • Members
  • Real Name:Sven
  • Location:Rotterdam, NL

Posted 04 June 2019 - 04:34 PM

Thanks!

 

It indeed says it's a boolean so that makes sense.

 

This HitBy property sounds good, even if it keeps track of the total things that hit the enemy I could surely use this in some way. I hope ZoriaRPG can elaborate on that! :-)

 

Even if the functionality is unfinished, I don't expect to finish my quest within 1-2 years, so I'd be happy to wait.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users