PDA

View Full Version : help with an enemy...



Master Maniac
10-10-2007, 01:14 AM
ok i dont know if this one has been created yet, but i need a script where an enemy will mimic your moves and only fire a weapon if it is pointing directly at the player. im using build 584. Thanks

ShadowMancer
10-10-2007, 10:14 PM
ffc script follower{
void run(int id){
int LinkX; int LinkY;
npc ene = Screen->CreateNPC(id);
while(ene->isValid())
{
ene->X = this->X;
ene->Y = this->Y;
LinkX = Link->X;
LinkY = Link->Y;
Waitframe();
if (Link->X > LinkX) {ene->Dir = 2; if (is_walkable(this->X-4,this->Y)){this->X -= 4;} }
if (Link->X < LinkX) {ene->Dir = 3; if (is_walkable(this->X+4,this->Y)){this->X += 4;} }
if (Link->Y > LinkY) {ene->Dir = 0; if (is_walkable(this->X,this->Y-4)){this->Y -= 4;} }
if (Link->Y > LinkY) {ene->Dir = 1; if (is_walkable(this->X-4,this->Y)){this->Y += 4;} }
}
}
}

bool is_walkable(int x, int y)
{
if(x<0 || x>240 || y<0 || y>160)
{
return false;
}
return Screen->ComboS[y+(x>>4)]==0;
}


Alright, I wrote this in like 10 minutes so its untested, also the weapon fireing is not implimented yet. If you would like to test it and see if this is the kind of movement you had in mind (and if it works!) Let me know, I'll write the fireing script for you as well, but not tonight, gotta work tommarow. The script as it is should create an enemy of your choice (put enemy ID in argument 0) and have it mirror Link's movement (just like those enemies in Lttp, that is what I assumed you wanted to model this after) Well let me know what you think.

Master Maniac
10-11-2007, 05:56 PM
ok so everywhere there is a 0 i put the enemy ID? also it wont let me copy and paste... how do i make it work?

ShadowMancer
10-11-2007, 10:10 PM
Okay, to get the script into ZQ:
If you already are useing some scripts:
In ZQ, tools->Scripts - Compile ZScript - Export.
Then open the file you exported (in notepad) and add the script to it. save it
Tools->Scripts - Compile ZScript - Import. Compile. Assign the script to an FFC slot

If this is the first script you are adding:
copy this script to a notepad
add this as the first line:
import "std.zh"
save as a .Z file (save as type All files)
Tools->Scripts - Compile ZScript - Import. Compile. Assign the script to an FFC slot

on the screen where you want the enemy,
Data->Freefrom Combos. Choose one, Edit.
Data Tab: Choose an invisible combo (NOT COMBO #0). Xpos,Ypos the cords you want your enemy to appear at (I can add in a random appearence if you like)
Script drop box, choose the script slot number you assiged this script to
Flags: Check 'Run script at screen init'
Arguments tab: D0: Enemy ID

Good to Go :)

Master Maniac
10-11-2007, 11:59 PM
ok... lol ill attempt to understand this

Pheonix
10-13-2007, 01:35 AM
Ooh... some nasty puzzles could be done with this... Could you make one that does the same thing, except with the directions the enemy moves reversed (as in, you move left, it moves right)?

ShadowMancer
10-13-2007, 02:05 AM
Could you make one that does the same thing, except with the directions the enemy moves reversed (as in, you move left, it moves right)?
Actually that is what it does now. Just like the Green/Red Goryia 2 in Lttp
http://www.filespace.org.nyud.net:8090/ShadowMancer/Green_Goryia_2.gifhttp://www.filespace.org.nyud.net:8090/ShadowMancer/Red_Goryia_2.gif

Gleeok
10-13-2007, 03:26 AM
Ooooooohhh!! Oooh! How about for weapons they fire a a stream of lasers, rapid fire lasers. Like 6 ffc's a second! And, and, use some Ax and Ay action so they bend towards Link's position. Ahahaha!!!

Warp link to the center of a room where he's surrounded by 'em, now that's a puzzle!!!

Good use for if(Abs(this->X == Link->X) + 8//-8){ fire lasers!;}

How about omnidirectional enemy fire?


Ah, Teleporting ffc statues! ..if(Link->InputB){ this->X etc...; }


Hey, you could recreate those Skeletons that jump back when attacked from LTTP. ......Plus make them counterattack! You don't even need ffc life, just keep this->X,Y at enemyNPC->X,Y, and move the enemy accordingly.

I just got a bunch of ideas...Anyway, howabout a variable that allows the user to specify enemy difficulty? If you want to finish the basic script I'd be happy to add much evilness to it.

Master Maniac
10-20-2007, 05:04 PM
umm its not working right...[yes i just got around to testing it] when i try to import the file it says," unable to parse instruction from script mirror enemy ,the error was: invalid instruction, the command was (script) (follower{,)

... im not even in the beginning stages of being able to translate this... can you please explain it?