Jump to content

Photo

Ghosted Zols and Gels Combining and Splitting


  • Please log in to reply
13 replies to this topic

#1 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 01 January 2017 - 10:47 PM

does anybody know how to do this?

 

I need to know how to access the splitted gels ghost variables and how to check if two gels collide

 

 


Edited by Shadowblitz16, 01 January 2017 - 11:31 PM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 January 2017 - 04:32 PM

does anybody know how to do this?

 

I need to know how to access the splitted gels ghost variables and how to check if two gels collide

 

To combine two npcs on collision, or based on distance, try:

 

 
const int NPC_COMBINE_DISTANCE = 10;
const int COMBINE_ON_COLLISION = 0; //1 == collision, 0 == distance
void CombineNPCs(int old_npc_id, int new_npc_id){
 int npcs[3]; int q[2];
 for ( q[0] = Screen->NumNPCs(); q[0] > 0; q[0]++ ) {
  npcs[0] = Screen->LoadNPC(q[0]);
  if ( npcs[0]->ID == old_npc_id ) {
   for ( q[1] = q[0]+1; q[1] <= Screen->NumNPCs(); q[1]++ ) {
    npcs[1] = Screen->LoadNPC(q[1]);
    if ( q[1]->ID == old_npc_id ) {
     if ( NPCS_COMBINE_ON_COLLISION ) {
      if ( Collision(npcs[0], npcs[1] ) {
       npcs[2] = Screen->CreateNPC(new_npc_id);
       Remove(npcs[0]); Remove([npcs[1]);
      } 
     }
     else {
      if ( NPC_DistXY(npcs[0], npcs[1], NPC_COMBINE_DISTANCE ) {
       npcs[2] = Screen->CreateNPC(new_npc_id);
       Remove(npcs[0]); Remove([npcs[1]);
      }
     }
    }
   }
  }
 }
}
//base enemy, combine into, base enemy, combine into, ...
int NPC_CombineList[]={NPC_GEL, NPC_ZOL, NPC_GELFIRE, NPC_ZOLFIRE};

void CombineNPCs(int list){
 int npcs[3]; int q[10]; //q[5] = type
 q[4] = SizeOfArray(list)
 for ( q[0] = Screen->NumNPCs(); q[0] > 0; q[0]++ ) {
  npcs[0] = Screen->LoadNPC(q[0]);
  for ( q[3] = 0; q[3] < q[4]; q[3]+=2 ) {
   if ( npcs[0]->ID == q[3] ) {
    q[5] = list[ q[3] ];
    for ( q[1] = q[0]+1; q[1] <= Screen->NumNPCs(); q[1]++ ) {
     npcs[1] = Screen->LoadNPC(q[1]);
     if ( q[1]->ID == q[5] ) {
      if ( NPCS_COMBINE_ON_COLLISION ) {
       if ( Collision(npcs[0], npcs[1] ) {
        npcs[2] = Screen->CreateNPC(new_npc_id);
        Remove(npcs[0]); Remove([npcs[1]);
       } 
      }
      else {
       if ( NPC_DistXY(npcs[0], npcs[1], NPC_COMBINE_DISTANCE ) {
        npcs[2] = Screen->CreateNPC(new_npc_id);
        Remove(npcs[0]); Remove([npcs[1]);
       }
      }
     }
    }
   }
  }
 }
}
  
bool NPC_DistXY(npc a, npc b, int distance) {
 int distx; int disty;
 if ( a->X > b->X ) distx = a->X - b->X;
 else distx = b->X - a->X;
 
 if ( a->Y > b->Y ) disty = a->Y - b->Y;
 else disty = b->Y - a->Y;
 return ( distx <= distance && disty <= distance );
}


#3 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 02 January 2017 - 04:55 PM

thankyou but I don't understand your code

also what about editing spawned gels attribute for splitting?

I need to edit their Ghost_Jump variables


Edited by Shadowblitz16, 02 January 2017 - 05:19 PM.


#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 January 2017 - 05:39 PM

All you need ti do is call one of those two functions, either in your ghist ffc, or in your global script.

The second accepts a list, where enemy a is replaced with enemy b, from the list.

The first, you would just call as:

CombineNPCs(this->ID, NPC_ZOL) if you have a ghost ffc attached to an npc that you want to combine into a Solution.

Split on hit works from the enemy editor only on specific enemy types, but sure. You could use npc->Attributes[] in the function calls in your scripts, rather than a list ir hard coding them.

#5 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 02 January 2017 - 07:29 PM

ZoriaRPG I don't like the way the slime split works in zquest also I don't know how to access the ghost variables from a spawned enemy from i n the enemy that spawned it

also I mean't like I don't understand your code I would like to understand it so that I can learn from it. can you comment telling me what everything is and does? 



#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 January 2017 - 08:16 PM

ZoriaRPG I don't like the way the slime split works in zquest also I don't know how to access the ghost variables from a spawned enemy from i n the enemy that spawned it
also I mean't like I don't understand your code I would like to understand it so that I can learn from it. can you comment telling me what everything is and does?

 
Working on it for you.
 
How's this?
 
 


I also put it up on Pastebin so that it's easier to read.

Note: I did not yet compile, or test this. If you encounter problems, and canna fix them, just let me know.

Edited by ZoriaRPG, 02 January 2017 - 08:36 PM.


#7 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 02 January 2017 - 09:40 PM

thankyou so much I will review the code

 

however I have one more question

is there a way to set a script to run when a ghosted enemy dies?

right now I am checking if the enemy is dead after every waitframe and before every loop in my slime script however it doesn't seem like its working.



#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 January 2017 - 09:45 PM

thankyou so much I will review the code
 
however I have one more question
is there a way to set a script to run when a ghosted enemy dies?
right now I am checking if the enemy is dead after every waitframe and before every loop in my slime script however it doesn't seem like its working.


if ( ghost->HP <= 0 ) RunFFCScript(...);
You can also call RunFFCScript() in your Ghost_Waitframe(), if you wrote a custom Ghost_Waitframe() function for the enemy.

Alternatively, if your ghost ffc script uses while(condition) instead of while(true), you can call RunFFCScript() after the loop, so that when the main loop ends, it calls RunFFCScript() on the next frame.

#9 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 02 January 2017 - 11:30 PM

ok thankyou so much you've been very helpful

 

sadly I forgot to ask one of my questions when I actually said it was my last question

however I'm going to aks it anyways

 

is there a way to make the slimes death effect not fall when the slime is killed in the air?

right now when I kill the slime in the air the death effect falls like the slime is falling



#10 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 January 2017 - 11:41 AM

ok thankyou so much you've been very helpful
 
sadly I forgot to ask one of my questions when I actually said it was my last question
however I'm going to aks it anyways
 
is there a way to make the slimes death effect not fall when the slime is killed in the air?
right now when I kill the slime in the air the death effect falls like the slime is falling


Try setting its n->Jump immediately to 0 when it dies.

#11 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 03 January 2017 - 12:04 PM

ok thankyou

 

EDIT: ZoriaRPG you never set "old_npc_id" to anything what is it supposed to be?

I'm guessing the gel from the first loop index right? 

 

EDIT 2: you also seem to use an int to store your loaded npc's which throws an error

 

EDIT 3: setting Ghost_Jump to 0 is not working with the falling death effect it still seems to fall to the ground


Edited by Shadowblitz16, 03 January 2017 - 03:09 PM.


#12 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 03 January 2017 - 03:09 PM

ZoriaRPG you there?

 

I have this code right here

but it seems that the gels z position are being set to what the jump should be even though I have no code setting it 60/10

 

right now the gels warp up high with the additional jump velocity when splitting instead of starting at the zols z position with the additional jump velocity

 

void Zol_Tribble(ffc this, npc ghost, int child, int height, bool tribble) {
 
if (!tribble) return;
    if (Ghost_GotHit() && Ghost_HP  > -999 ) { //If the base enemy is at the brink of death...
 
//Stop slime velocity
Ghost_Vx = 0;
Ghost_Vy = 0;
 
//Check if flash flag is set and if so flash
if (Z4ZOL_FLASH_BEFORE_SPLIT)
{
Ghost_StartFlashing(32);
Ghost_Waitframes(this, ghost, false, false, 32);
}
 
//Spawn smaller slimes
npc gel1 = Screen->CreateNPC(child); //Create two enemies in its place.
npc gel2 = Screen->CreateNPC(child);//Based on its 'Death Attribute 3' value.
       
//If we set a sound for tribbling npcs, play it.
        if ( Z4ZOL_TRIBBLE_SFX > 0 ) Game->PlaySound(0);
        
        //Spawn smaller slime 1 and set its x, y, and jump                    
        gel1->X = Ghost_X + 1 * 4; //Place the new npcs at the location of the
        gel1->Y = Ghost_Y + 0; //enemy that we are replacing, -/+
gel1->Z = Ghost_Z;
if (Z4ZOL_BOUNCE_AFTER_TRIBBLE) gel1->Jump = 60/10;
 
//Spawn smaller slime 2 and set its x, y, and jump 
        gel2->X = Ghost_X - 1 * 4; //a randomised distance.
        gel2->Y = Ghost_Y + 0;
gel2->Z = Ghost_Z;
if (Z4ZOL_BOUNCE_AFTER_TRIBBLE) gel2->Jump = 60/10;
 
//Silently kill the bigger slime, removing it fully.
        Ghost_HP = -9999; 
Ghost_X  = -9999;
Ghost_Y  = -9999;
    }
}   

Edited by Shadowblitz16, 03 January 2017 - 06:02 PM.


#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 04 January 2017 - 01:20 AM

ZoriaRPG you there?
 
I have this code right here
but it seems that the gels z position are being set to what the jump should be even though I have no code setting it 60/10
 

gel2->Z = Ghost_Z;
if (Z4ZOL_BOUNCE_AFTER_TRIBBLE) gel2->Jump = 60/10;


As I recall, Ghost_Z sets Y, and [ossibly Jump properties. I know that Ghost fakes Z-axis and some Jumping attributes.

What is the problem that this is causing? Just set Ghost_Z to 0, along with n->Z and n->Jump or whatever values you are using, when the enemy dies, to 0.

Why are you using an equation ( 60 / 10 ) instead of 6?

 
//Silently kill the bigger slime, removing it fully.

        Ghost_HP = -9999; 
Ghost_Z  = 0;
ghost->Jump = 0;
Also...

if (Ghost_GotHit() && Ghost_HP  > -999 ) { //If the base enemy is at the brink of death...
You probably want:
&& Ghost_HP <= 0
in that statement...:

if (Ghost_GotHit() && Ghost_HP  > -999  && Ghost_HP <= 0  ) { //If the base enemy is at the brink of death...
Hell, the function isn't even setting up the Ghost_* values, and there are no inputs for them. Ghost.zh might be able to live with that, though.

I don't remember all of this stuff off-hand, but I could swear that Ghost_GotHit(...) required an input, either as Ghost_GotHit(ffc f) or Ghost_GotHit(npc n).

You further declared int child, int height in the params, but these are not used. It looks very much like an incomplete function...?

Was there something specifically wrong with the functions that I gave to you?

Edited by ZoriaRPG, 04 January 2017 - 01:31 AM.


#14 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 04 January 2017 - 02:16 PM

I am trying to make the gels split when they are hit not when they die

then I want to make them flash a while if a certain constant is set and then I want to set their z position(jump position) to that of the zol and then add z velocity(jump velocity)

 

the function Ghost_GotHit() said in the Ghost.zh docs that it didn't take any parameters

 

also I am using the child and height variable I just set the to values so you know what they were and I am dividing height by 10 so they people can specify a more accurate jump height

 

also the script you gave me look fine now that I look at it I will get back to you if it throws any more errors




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users