Jump to content

Photo

Tracking Moldorm Parts with Ghost

Ghost NPC Enemy

  • Please log in to reply
2 replies to this topic

#1 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 25 January 2015 - 12:21 AM

Just as the topic says, could you track the remaining parts of a Moldorm by script? My idea is to have the npc do various thing based on the number of body parts left over. How does the engine track parts attached to an "type: Moldorm" enemy?



#2 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 25 January 2015 - 11:05 AM

Yes but there's something about them segmented enemies: Moldorm, Lanmola, Manhandla, Gleeok, and Patra cannot use AutoGhost(), well at least directly. I usually do something like this.

ffc script SegmentedEnemyBase //Note that these use Spawn Animation Instant.
{
	//Type should be other.
	//Attribute 0 is the ID of the segmented enemy.
	void run(int fakeID) //EnemyID
	{
		npc ghost = Ghost_InitAutoGhost(this, enemyID);
        if(ghost->Attributes[0]>=AUTOGHOST_MIN_ENEMY_ID &&
		   ghost->Attributes[0]<=AUTOGHOST_MAX_ENEMY_ID) //These settings are found in ghost.zh 20 and 511 by default.
		{
			npc newghost = CreateNPC(ghost->Attributes[0]);
			Ghost_Replace(ghost, newghost, false);
			ghost = newghost; //newghost will fall out of scope, so we store the newghost in the old parameter.
		}
		else
		{
			ghost->HP=HP_SILENT;
			ghost->X=1000;
			Quit();
		}
		//Continue your code from here...
	}
}

The only problem you'll have with moldorms is their segment spawning delay. My solution might work, it might not.

1. Set step to 0.

2. Ghost_Waitframe load each Moldorm and check if it's a ghost_ZH enemy. I belive this hard coded based off step speed. but when 0 u

3. The segments that follow those should be the moldorm segments load them into an array if their not a ghostzh enemy

4. I'll get back to you but this involves Ghost_ForceDir and Constantwalk8



#3 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 25 January 2015 - 01:37 PM

import "std.zh"
import "string.zh"
import "ghost.zh"
import "ffcscript.zh"

ffc script SegmentedEnemyBase //Note that these use Spawn Animation Instant.
{
	//Type should be other.
	//Attribute 0 is the ID of the segmented enemy.
	void run(int enemyID) //EnemyID
	{
		npc dummy; = Ghost_InitAutoGhost(this, enemyID);
		npc ghost;
        if(ghost->Attributes[0]>=AUTOGHOST_MIN_ENEMY_ID &&
		   ghost->Attributes[0]<=AUTOGHOST_MAX_ENEMY_ID) //These settings are found in ghost.zh 20 and 511 by default.
		{
			ghost = Screen->CreateNPC(ghost->Attributes[0]);
			Ghost_SwapNPC(dummy, ghost, false);
		}
		else //Don't forget to set attribute 0 or face the wrath of disappearing enemies!
		{
			dummy->HP=HP_SILENT;
			dummy->X=1000;
			Quit();
		}
		npc segments[5]; //<-- CHANGE THIS NUMBER TO REFLECT THE NUMBER OF SEGMENTS
		int segcnt=Ghost_GetAttribute(ghost,0,1);
		int index;
		float step = ghost->Step/100;
		int counter = Floor(8/step);
		while(Ghost_HP>0)
		{
			if(index<segcnt)
			{
				if(counter<=0)
				{
					segments[index]=GetNextSegment(this,ghost,segments,index);
					counter = Floor(8/step);
					index++;
				}
				else
					counter--;
			}
			else
			{
				//If we get here then the moldorms segments are stored in the array.
				//Let's celebrate by flashing through CSet 6-13!
				int cset=6+Rand(8);
				for(int i; i < segcnt; i++)
				{
					segments[i]->CSet=cset;
				}
			}
			Ghost_Waitframe2(this,ghost,false,true); //Clearing segmented enemies on death is bad idea.
		}
		//It's dead kill the dummy
		Dummy->HP = HP_SILENT;
	}
	npc GetNextSegment(ffc this, npc ghost, npc segments, int index)
	{
		npc next;
		for(int i = Screen->NumNPCs(); i > 0; i--)
		{
			npc n = Screen->LoadNPC(i);
			if(Ghost_IsInUse(n)) continue;
			else
			{
				Ghost_MarkAsInUse(n);
				next=n;
				break;
			}
		}
		return next;
	}
}

That should store the parts of a moldorm in an array called segments for you. And make them disco flash through CSet 6-13 if successful. I only tested this with a single moldorm though. As for step speed set it as normal. And use a dummy enemy to place it with attribute set to the moldorms ID.





Also tagged with one or more of these keywords: Ghost, NPC, Enemy

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users