PDA

View Full Version : "Ally" Script



Revfan9
01-07-2007, 07:30 AM
I'm trying to write a script that makes an "Ally" follow Link directly behind his back, and when there are enemies around, it chases after enemy1, then after enemy1 is dead, it goes onto enemy2, and so on. If link kills enemy2 before the ally kills enemy1, it just goes on to enemy 3. I have the script that makes the ally follow Link...


WAIT WAITFRAME
COMPAREV LINKDIR,0
GOTOTRUE DOWN
COMPAREV LINKDIR,1
GOTOTRUE UP
COMPAREV LINKDIR,2
GOTOTRUE LEFT
COMPAREV LINKDIR,3
GOTOTRUE RIGHT
GOTO WAIT
DOWN SETR d4,LINKY
ADDV d4,16
SETR y,d4
SETR x,LINKX
SETR DATA,d0
GOTO WAIT
UP SETR d4,LINKY
SUBV d4,16
SETR y,d4
SETR x,LINKX
SETR DATA,d1
GOTO WAIT
LEFT SETR d4,LINKX
ADDV d4,16
SETR x,d4
SETR y,LINKY
SETR DATA,d2
GOTO WAIT
RIGHT SETR d4,LINKX
SUBV d4,16
SETR x,d4
SETR y,LINKY
SETR DATA,d3
GOTO WAIT

But I have no idea how to log the positions of enemies, or damage an enemy. Can I get some help on this?

C-Dawg
01-07-2007, 02:13 PM
In ZASM? Nope.

Revfan9
01-09-2007, 04:11 AM
Okay then... Could you help me in Zscript?

Saffith
01-10-2007, 03:06 PM
See, here's the thing: there seems to be a bit of a bug keeping REFFFC and REFNPC from being set correctly. I can tell you what I think you would do, but neither of us can really test it to make sure right now. You'll have to put this off until at least beta 17.


The number of enemies on the screen is stored in NPCCOUNT. You load a reference to an NPC by setting the value of REFNPC - the first enemy is 0. With that, you can read and set that enemy's position with NPCX, NPCY, and NPCZ, and you can access its HP using NPCHP.

I'm not sure, but I think NPCs include both guys and enemies, and I don't believe there's a way to check which you've got directly. There's sure to be some way of knowing, though.
The amount of damage an NPC does when it touches link is NPCDP, and its weapon damage is NPCWDP. I figure if those are both 0 or less, it probably shouldn't be considered an enemy.

Revfan9
01-10-2007, 10:25 PM
Thank you Saffith! As always, you are in my debt (whatever good that does...).

So, I can set REFNPC to increment on NPCHP being 0, then moving the FFC torwards NPCX,NPCY by comparing x,y and changing the combo/moving accordingly. When the FFC and the target NPC are touching, the NPC takes damage... Then when all NPCs are dead, it returns behind Link...

This will help me a lot with level 2 of my quest... Thank you!

Sir-Pimpalot
01-14-2007, 01:38 AM
This'll be a nice one! :) Sorry, nope I'm of no help. :P