PDA

View Full Version : Enemy Harvesting Failure, Help!



CJC
06-08-2008, 05:21 PM
I'm trying to write a script that harvests an enemy's movement pattern, changes its appearance under certain conditions, and spawns a variety of melee and ranged weapons under certain conditions. This is what I came up with. Before I start, I have to lay out a few principles of the script.

D0, D1, and D5 will be changed eventually to detect enemy spawn flags in use. Once the basic premise of the code is complete, it will be compressed to D0 (Which will dictate which enemy flag to start on) and D1 (Which will dictate how many enemies to spawn on each subsequent enemy flag). I may need a failsafe for D1 if the flag would exceed Enemy flag 9, though I am unsure how to code such a thing.
The script is currently using the enemy integer "Extend". There is no verification one way or another whether this feature is functional (The Wiki says it is not, but the ZScript text implies it is. Either way, it will be implemented eventually and has little effect on the remainder of the function.
The script changes enemy animation by changing the tile that standard animation begins on. I don't know if writing to this integer is possible, so that aspect of the code may be flawed.
Currently, the script spawns the enemy in the correct location but DOES NOT change their appearance or behavior.




//================================================== =======================
//D0 = The X coordinate of the Enemy on startup
//D1 = The Y coordinate of the Enemy on startup
//D2 = Sets the starting tile of the enemy. Assumes facing up.
//D3 = Sets the starting tile of the Spear's tip. The Spear handle will use the next tile.
//D4 = Sets the starting tile of the Arrow. Assumes facing left, and the next tiles will make right, up, and down.
//D5 = Must be set to 1. Will change in later versions.
//================================================== =======================

ffc script Moblin{
void run(int MobX, int MobY, int Refresh, int SpearTipTile, int ArrowTile, int MobSpawn){
npc Moblin = Screen->LoadNPC(28);//Loads Moblin Level 1
Moblin->HP = 12;
Moblin->CSet = 7;
Moblin->Extend = 2;
if(MobSpawn>=1){
MobSpawn = MobSpawn -1;
Screen->CreateNPC(28);
Moblin->X = MobX;
Moblin->Y = MobY;
}
eweapon SpearHandle = Screen->LoadEWeapon(1);
eweapon SpearTip = Screen->LoadEWeapon(1);
eweapon SteelArrow = Screen->CreateEWeapon(130);
int MoblinAttacktmr;
while(true){
Moblin->ASpeed = 6;
Moblin->DrawStyle = 3; //Makes the enemy animate like Link does.
Moblin->Step = 2;
Moblin->Haltrate = 4;
Moblin->Rate = 3;
SteelArrow->CSet = 10;
SpearHandle->CSet = 10;
SpearTip->CSet = 10;
MoblinAttacktmr--;
if(MoblinAttacktmr<=0){MoblinAttacktmr = 0;}
if(Moblin->Dir==0){
Moblin->Tile = Refresh;
}
else if (Moblin->Dir==1){
Moblin->Tile = Refresh +40;
}
else if (Moblin->Dir==2){
Moblin->Tile = Refresh +80;
if((Link->X+15==Moblin->X-16 || Link->X+15==Moblin->X-32 || Link->X+15==Moblin->X-40) && MoblinAttacktmr==0){
SpearHandle->X = Moblin->X-16; SpearHandle->Y = Moblin->Y; SpearHandle->Step = 2;
SpearTip->X = Moblin->X-32; SpearTip->Y = Moblin->Y; SpearTip->Step = 2;
Moblin->WeaponDamage = 8;
Moblin->Tile = Refresh +8;
Moblin->ASpeed = 12;
Moblin->Haltrate = 128;
Moblin->Rate = 0;
MoblinAttacktmr = 8;
}
if(Link->Y==Moblin->Y && MoblinAttacktmr==0){
SteelArrow->X = Moblin->X-16; SteelArrow->Y = Moblin->Y; SteelArrow->Step = 3;
Screen->DrawTile(3, Moblin->X-8, Moblin->Y, ArrowTile, 1, 1, 10, 1, 0, 0, 0, 0, true, 128);
Moblin->WeaponDamage = 4;
Moblin->Tile = Refresh +88;
Moblin->ASpeed = 12;
Moblin->Haltrate = 128;
Moblin->Rate = 0;
MoblinAttacktmr = 5;
}
}
else if (Moblin->Dir==3){
Moblin->Tile = Refresh +120;
if((Link->X-15==Moblin->X+16 || Link->X-15==Moblin->X+32 || Link->X-15==Moblin->X+40) && MoblinAttacktmr==0){
SpearHandle->X = Moblin->X+16; SpearHandle->Y = Moblin->Y; SpearHandle->Step = 2;
SpearTip->X = Moblin->X+32; SpearTip->Y = Moblin->Y; SpearTip->Step = 2;
Moblin->WeaponDamage = 8;
Moblin->Tile = Refresh +48;
Moblin->ASpeed = 12;
Moblin->Haltrate = 128;
Moblin->Rate = 0;
MoblinAttacktmr = 8;
}
if(Link->Y==Moblin->Y && MoblinAttacktmr==0){
SteelArrow->X = Moblin->X+16; SteelArrow->Y = Moblin->Y; SteelArrow->Step = 3;
Screen->DrawTile(3, Moblin->X+8, Moblin->Y, ArrowTile, 1, 1, 10, 1, 0, 0, 0, 2, true, 128);
Moblin->WeaponDamage = 4;
Moblin->Tile = Refresh +128;
Moblin->ASpeed = 12;
Moblin->Haltrate = 128;
Moblin->Rate = 0;
MoblinAttacktmr = 5;
}
}
else{
Moblin->Tile = Refresh +40;
}
Waitframe();
}//End of While Loop
}//End of Void Run
}


HELP!