While writing the portion of stdWeapons.zh header that handles special interaction with enemies I have stumbled upon a little (or not) problem: enemy`s shield can be intact or broken (by hammer or via "npc->BreakShield()" function). And my function that checks if Lweapon hits shielded side of the enemy may return false positive if enemy`s shield is broken and any scripted weapon that uses this function will behave like if it`s blocked by (non-existent) enemy shield. Here is the function:
// Returns a counter-clockwise direction in 4-way compass int CCWDir4way (int dir){ if (dir == DIR_UP) return DIR_LEFT; if (dir == DIR_LEFT) return DIR_DOWN; if (dir == DIR_DOWN) return DIR_RIGHT; if (dir == DIR_RIGHT) return DIR_UP; else return -1; } // Returns a clockwise direction in 4-way compass int CWDir4way (int dir){ if (dir == DIR_UP) return DIR_RIGHT; if (dir == DIR_RIGHT) return DIR_DOWN; if (dir == DIR_DOWN) return DIR_LEFT; if (dir == DIR_LEFT) return DIR_UP; else return -1; } // Returns TRUE if lweapon collides with shielded side of the enemy. bool BlockedByShield(lweapon l, npc n){ if (!Collision(l,n)) return false; if (GetNPCMiscFlag(n, 0x0200)){ if (l->Dir== OppositeDir(n->Dir)) return true; else return false; } else if (GetNPCMiscFlag(n, 0x1000)){ if (l->Dir == n->Dir) return true; else return false; } else if (GetNPCMiscFlag(n, 0x0400)){ if (l->Dir==CCWDir4Way(n->Dir)) return true; else return false; } else if (GetNPCMiscFlag(n, 0x0800)){ if (l->Dir==CWDir4way(n->Dir)) return true; else return false; } return false; }
Any way to make that fuction work propely with breakable enemy`s shields?
Edited by Alucard648, 17 April 2014 - 03:28 PM.