ghost.zh
#181
Posted 09 December 2012 - 09:15 PM
#182
Posted 09 December 2012 - 09:36 PM
Anyhow, thanks!
#183
Posted 10 December 2012 - 01:16 AM
#184
Posted 14 December 2012 - 04:52 PM
I can confirm that the function is working, but it just won't heal. I ran a Drawprimitive gauge to confirm that it isn't healing but the healing animation works as intended. Also, I wonder why Ghost_HP is somehow undeclared in this function. An error perhaps? Mind you that I am using an older version of Ghost.zh, with the init functions with the flag augments, but I haven't seen anything in the changelog that relates to Ghost_HP.
Edit: I would also like to have certain EWeapons bounce off walls. Hopefully it would be simple to do.
Edited by Orin XD, 14 December 2012 - 05:12 PM.
#185
Posted 14 December 2012 - 05:32 PM
There's no movement type in ghost.zh to make eweapons reflect, but it's not too hard.
float yComp=RadianSin(wpn->Angle);
bool reflect=false;
if((xComp<0 && Screen->isSolid(wpn->X+2, wpn->Y+8)) ||
(xComp>0 && Screen->isSolid(wpn->X+14, wpn->Y+8)))
{
reflect=true;
xComp=-xComp;
}
if((yComp<0 && Screen->isSolid(wpn->X+8, wpn->Y+2)) ||
(yComp>0 && Screen->isSolid(wpn->X+8, wpn->Y+14)))
{
reflect=true;
yComp=-yComp;
}
if(reflect)
wpn->Angle=ArcTan(xComp, yComp);
You might need to fiddle with it a bit, but that's the general idea.
#186
Posted 20 December 2012 - 08:51 PM
my script
import "string.zh"
import "ghost.zh"
const float TWA_JUMP_SPEED=2; // Speed in pixels per frame when jumping
// npc->Attributes[] indices
const int TWA_ATTR_SLIME_ID=0;
const int TWA_ATTR_JUMP_SOUND=1;
const int TWA_ATTR_LAND_SOUND=2;
const int TWA_ATTR_JUMPY=3;
ffc script TwinAmoeba
{
void run(int enemyID)
{
npc ghost;
npc slime[2];
int currentSlime;
bool jumpy;
lweapon wpn;
int i;
// Initialize
ghost=Ghost_InitAutoGhost(this, enemyID);
Ghost_SetFlag(GHF_NO_FALL);
Ghost_SetFlag(GHF_CLOCK);
Ghost_SetFlag(GHF_SET_OVERLAY);
Ghost_SpawnAnimationPuff(this, ghost);
currentSlime=0;
jumpy=ghost->Attributes[TWA_ATTR_JUMPY]!=0;
// Create the first slime at the core's position; the second is randomly placed
slime[0]=Screen->CreateNPC(ghost->Attributes[TWA_ATTR_SLIME_ID]);
slime[0]->X=Ghost_X;
slime[0]->Y=Ghost_Y;
slime[1]=SpawnNPC(ghost->Attributes[TWA_ATTR_SLIME_ID]);
Ghost_SetAllDefenses(slime[0], NPCDT_IGNORE);
Ghost_SetAllDefenses(slime[1], NPCDT_IGNORE);
while(true)
{
// If the core just got hit, jump to the other slime
if(Ghost_GotHit())
{
SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], true);
currentSlime^=1; // Switch index between 0 and 1
}
// If Link is too close and the other slime is farther, jump over
else if(Distance(Ghost_X, Ghost_Y, Link->X, Link->Y)<32)
{
if(SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], false))
currentSlime^=1;
}
else if(jumpy)
{
// Jumpy ones jump whenever a weapon is too close
for(i=Screen->NumLWeapons(); i>0; i--)
{
wpn=Screen->LoadLWeapon(i);
// This could be a lot of checks, so just look at X and Y difference
if(Abs(wpn->X-Ghost_X)<32 && Abs(wpn->Y-Ghost_Y)<32)
{
SlimeJump(this, ghost, slime[currentSlime], slime[currentSlime^1], true);
currentSlime^=1;
break;
}
}
}
Ghost_X=slime[currentSlime]->X;
Ghost_Y=slime[currentSlime]->Y;
TwAWaitframe(this, ghost, slime[0], slime[1]);
}
}
// Jump from one slime to the other. If not forced, it won't jump if the other slime is
// closer to Link. Returns true if it jumps, false if not.
bool SlimeJump(ffc this, npc ghost, npc startSlime, npc destSlime, bool force)
{
// If not forced, see if the destination slime is closer to Link than the starting slime;
// if so, don't do anything
if(!force)
{
if(Distance(startSlime->X, startSlime->Y, Link->X, Link->Y)>=Distance(destSlime->X, destSlime->Y, Link->X, Link->Y))
return false;
}
int startX;
int startY;
int targetX;
int targetY;
float angle;
float totalDist;
float currentDist;
// Ignore clocks while jumping so the core doesn't get stuck in midair
Ghost_UnsetFlag(GHF_CLOCK);
Game->PlaySound(ghost->Attributes[TWA_ATTR_JUMP_SOUND]);
// Jump
do
{
// Get the current position of the two slimes
startX=startSlime->X;
startY=startSlime->Y;
targetX=destSlime->X;
targetY=destSlime->Y;
// Move toward one from the other
angle=Angle(Ghost_X, Ghost_Y, targetX, targetY);
Ghost_X+=VectorX(TWA_JUMP_SPEED, angle);
Ghost_Y+=VectorY(TWA_JUMP_SPEED, angle);
// Set height based on how much of the total distance has been covered
totalDist=Distance(startX, startY, targetX, targetY);
currentDist=Distance(Ghost_X, Ghost_Y, targetX, targetY);
Ghost_Z=totalDist/2*Sin(currentDist/totalDist*180);
TwAWaitframe(this, ghost, startSlime, destSlime);
} while(currentDist>1);
Ghost_Z=0;
Ghost_SetFlag(GHF_CLOCK);
Game->PlaySound(ghost->Attributes[TWA_ATTR_LAND_SOUND]);
return true;
}
void TwAWaitframe(ffc this, npc ghost, npc slime1, npc slime2)
{
// The slimes should be invincible, but if one becomes invalid, kill everything
if(!slime1->isValid())
{
ghost->HP=0;
if(slime2->isValid())
slime2->HP=0;
this->Data=0;
Quit();
}
else if(!slime2->isValid())
{
ghost->HP=0;
slime1->HP=0;
this->Data=0;
Quit();
}
// Still valid - try to keep them alive, no matter what
else
{
if(slime1->HP<32768)
slime1->HP=32768;
if(slime2->HP<32768)
slime2->HP=32768;
}
// If the core is dead, kill the slimes as well
if(!Ghost_Waitframe(this, ghost, true, false))
{
slime1->HP=0;
slime2->HP=0;
Quit();
}
}
}
Help error noooooooo!
Pass 1: Parsing
Pass 2: Preprocessing
Can't open input file
ghost.zh, line 89: Error P01 : Failure to parse imported file ghost_zh/update.zh.
I'm using Autoghost script version 2.5 RC5 latest version
by Saffith
You probably didn't extract the ghost_zh directory, which needs to go into the ZC directory along with ghost.zh
I didn't see a ghost_zh directory in the ghost.zh download 2.5 RC5 version file
do you extract the files with a zip program first because I did that.Is there is a ghost_zh directory somwhere?
I did see the ghost_legacy.zh
Edited by Da Masta Sord, 20 December 2012 - 08:54 PM.
#187
Posted 21 December 2012 - 12:18 AM
#188
Posted 21 December 2012 - 01:46 AM
#189
Posted 21 December 2012 - 09:15 AM
Anyway, another small update, requiring 2.50. I added another way to set up AutoGhost enemies. Set misc. attribute 12 to -1 and put the script name in the enemy's name after @, for instance:
Goriya (LttP, green) @Goriya_LttP
Also, I added constants to control flashing and knockback, so now you can fling enemies clear across the screen if you like.
#190
Posted 21 December 2012 - 02:24 PM
Pass 2: Preprocessing
Pass 3: Building symbol tables
Pass 4: Type-checking/Completing function symbol tables/Constant folding
ghost_zh/global.zh, line 319: Error T28: That pointer type does not have a function GetFFCScript.
#191
Posted 21 December 2012 - 02:33 PM
#192
Posted 21 December 2012 - 05:32 PM
If we use this format is it okay to use Misc Attribute 11 for whatever we want?
#193
Posted 21 December 2012 - 07:21 PM
I added another way to set up AutoGhost enemies. Set misc. attribute 12 to -1 and put the script name in the enemy's name after @, for instance:
Goriya (LttP, green) @Goriya_LttP
This is beautiful. Thank you for that!
I will also have fun messing with the knockback bit. Is this something that can be set on a per-enemy basis or is it a global number?
#195
Posted 21 December 2012 - 07:41 PM
If we use this format is it okay to use Misc Attribute 11 for whatever we want?
No, you still need that for the combo. This doesn't allow you to do anything new, it's just meant to simplify setup a bit.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


