Jump to content

Photo

How the HECK do I fix this shadow issue? + Can I get some ghost tips?

shadowsghost tasty not-tasty

  • Please log in to reply
7 replies to this topic

#1 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 09 June 2018 - 11:30 PM

Excuse my language, I'm just very confused. For some reason my enemy's shadow is being drawn above the enemy itself rather than below:
A0MuMoVpPSyVAAAAAElFTkSuQmCC.png

I have no clue what's causing this. I even tried setting the "behind" flag on the shadow sprites. Here's the code:

ffc script PracticeEnemy
{
	void run(int enemyID)
	{
		int haltTime = 48;
		float counter = -1;
		
		
		npc ghost = Ghost_InitAutoGhost(this, enemyID);
		
		float MaxHP = Ghost_HP;
		
		float StepSpeed = ghost->Step;
		
		bool PhaseTriggered[2];
		int Phase = 0; // Starts at 0 because it's better to and you know it
		
		
		Ghost_SetSize(this, ghost, 2, 2);
		
		Ghost_SetFlag(GHF_4WAY);
		Ghost_SetFlag(GHF_SET_OVERLAY);
		
		while(true)
		{
			if(Phase == 0)
			{
				counter = Ghost_HaltingWalk4(counter, StepSpeed, ghost->Rate, ghost->Homing, ghost->Hunger, ghost->Haltrate, haltTime);
			
				if(counter == haltTime*(2/3))
				{
					FireEWeapon(EW_ARROW, Ghost_X, Ghost_Y, RadianAngle(Ghost_X, Ghost_Y, Link->X, Link->Y), 200, ghost->WeaponDamage, -1, -1, 0);
				}
				
				if(PhaseTriggered[Phase] == false)
				{
					if(Ghost_HP < MaxHP/2)
					{
						StepSpeed = StepSpeed * 2; // Arbitrary multiplication
						ghost->CSet = 10;
						
						PhaseTriggered[Phase] = true;
						Phase = Phase + 1; // So we don't go through the same phase over and over XD
					}
				}
			}
			
			if(Phase == 1)
			{
				counter = Ghost_ConstantWalk4(counter, StepSpeed, ghost->Rate, ghost->Homing, ghost->Hunger);
				
				if(Ghost_Z == 0)
				{
					Ghost_Jump = 2;
				}
			}
			
			
			Ghost_Waitframe(this, ghost, true, true);
		}
	}
}

(I think I may have overly complicated the boss phases with PhaseTriggered[], but I figured I'd keep it in there for now since it still works.)

 

Also, since I'm making an ENTIRE TOPIC, I figured I might as well also ask for general tips for using ghost.zh.



#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 10 June 2018 - 08:19 AM

I'm not super familiar with this particular problem, but if you want the enemy to have a shadow under it while it's walking, you'll probably just want to use a custom waitframe function that draws the shadow to layer 2 every frame. FFCs run before the global I believe, so this should draw the shadow under the enemy. It it's actually a flying enemy you can set the GHF_SET_OVERLAY flag and it'll draw the enemy to a higher layer while in the air. 

 

Here's two examples of how you'd make a custom waitframe function. Top one is kinda obvious, bottom one shows a couple of the extra tricks you can do:

void CustomWaitframe_Simple(ffc this, npc ghost){
	
	//Do whatever stuff you need done every frame
	
	//Do Ghost_Waitframe as usual
	Ghost_Waitframe(this, ghost);
}

void CustomWaitframe_Complex(ffc this, npc ghost, int vars){
	//Unpack any other array pointers you may need 
	//every frame from the vars[] array
	int array1 = vars[0];
	int array2 = vars[1];
	
	//Do whatever stuff you need done every frame
	
	//If Ghost_Waitframe returns false, the enemy has died
	if(!Ghost_Waitframe(this, ghost, false, false)){
		//Run a custom death effect based on the
		//__Ghost_Explode function found in ghost_zh/2.8/other.zh
		CustomDeathEffect(this, ghost);
		Quit();
	}
}


#3 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 10 June 2018 - 01:30 PM

The enemy is a walking one, but in its second phase I want it to bounce around. The bouncing part works properly, just not the shadow. I tried and setting or not setting the GHF_SET_OVERLAY flag doesn't seem to matter. I thought about decreasing GH_DRAW_OVER_THRESHOLD by a lot but that wouldn't fix the actual issue, just patch it up (at least as far as I know).


Edited by TheBlueTophat, 10 June 2018 - 01:33 PM.


#4 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 10 June 2018 - 02:49 PM

Try setting ghost->Extend=4 after initialization. That will disable built-in shadows and make ghost.zh draw them itself. You'll need to have the GH_SHADOW_ constants set cororectly.

#5 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 10 June 2018 - 04:24 PM

Try setting ghost->Extend=4 after initialization. That will disable built-in shadows and make ghost.zh draw them itself. You'll need to have the GH_SHADOW_ constants set cororectly.

Is there somewhere with documentation on what exactly different values of Extend do? I had no idea it had an effect on shadow drawing.



#6 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 10 June 2018 - 05:54 PM

Not that I'm aware of. But that's pretty much it, anyway.

0: 16x16
1: 16x32, tile is at bottom
2: 32x32, tile is at bottom-center
3: Variable size, tile is at top-left
4: Same as 3, but no shadow

#7 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 11 June 2018 - 01:10 AM

Setting ghost->Extend to 4 seems to have fixed the problem! Thanks!



#8 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 11 June 2018 - 03:55 PM

nvm


Edited by Avataro, 11 June 2018 - 03:56 PM.

  • coolgamer012345 likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users