So I've been working on a FSA-style bow script, breaking the development down into multiple phases - phase 1 being a bow that simply shoots an arrow whenever its used, and phase 2 (the current phase) being a bow that adds a slight delay (nocking) before firing. I pseudo-coded the logic and it's rock-solid, but due to my inexperience with ZScript the implementation isn't doing what I want... though I feel like I'm this close. Here's what I have so far:
import "std.zh" import "ffcscript.zh" const int NOCK_TIMER_END = 30; const int IC_FAUXBOW = IC_CUSTOM1; // BEGIN BOW SCRIPTS item script FauxBow { void run() { int scriptName[] = "FauxBow2_FFC"; int ffcScript = Game->GetFFCScript(scriptName); if (CountFFCsRunning(ffcScript) == 0) RunFFCScript(ffcScript, NULL); } } ffc script FauxBow_FFC { void run() { int bowID = GetHighestLevelItem(IC_FAUXBOW); int nockTimer = 0; bool nockingArrow = false; while (true) { // Phase 2 Bow Logic: if (UsingItem(bowID) && !nockingArrow) { // If trying to use bow, and no arrow being nocked: nockingArrow = true; // Start nocking an arrow. } else if (nockingArrow) { // Otherwise: if (nockTimer >= NOCK_TIMER_END) { // If nocking is done: ShootArrow(); // Shoot the arrow. nockTimer = 0; // Reset the nocking timer. nockingArrow = false; // No longer nocking an arrow. } else { // Otherwise: nockTimer++; // Continue nocking, incrementing the nocking timer. } } Waitframe(); } } void ShootArrow() { lweapon arrow = CreateLWeaponAt(LW_ARROW, Link->X, Link->Y); arrow->Dir = Link->Dir; arrow->Step = 300; if (Link->Dir == DIR_UP) arrow->Flip = 0; else if (Link->Dir == DIR_DOWN) arrow->Flip = 3; else if (Link->Dir == DIR_LEFT) arrow->Flip = 7; else if (Link->Dir == DIR_RIGHT) arrow->Flip = 4; } } // END BOW SCRIPTS
I'm pretty sure the only issue is in how I implemented the "trying to use bow" piece of the commented logic. I don't think I'm using UsingItem() correctly, but due to my lack of knowledge of the language I can't think of another way to put the idea into code. Can anyone fix or give guidance here? Thanks!