//stdCombos.zh // //This header is used to detect collision between various in-game objects and combos. //Return INT means return location of first combo that has tripped collision. // //v1.1 BETA //If you want just to check if an object collides with any combo with specific flag/type, use //piece of code like this: // // if (ComboTypeCollision (type, ffc)>=0){ // foo // } // // Returns TRUE if there is a collision between the combo and an arbitrary rectangle. bool ComboCollision (int loc, int x1, int y1, int x2, int y2){ return RectCollision( ComboX(loc), ComboY(loc), (ComboX(loc)+16), (ComboY(loc)+16), x1, y1, x2, y2); } // Returns TRUE if there is a collision between FFC and the combo on screen. bool ComboCollision (int loc, ffc f){ int ax = (f->X); int ay = (f->Y); int bx = ax+(f->EffectWidth); int by = ay+(f->EffectHeight); int cx = ComboX(loc); int cy = ComboY(loc); int dx = ComboX(loc)+16; int dy = ComboY(loc)+16; return RectCollision( cx, cy, dx, dy, ax, ay, bx, by); } // Returns INT if FFC collides with a combo of specific type int ComboTypeCollision (int type, ffc f){ for (int i=0; i<176; i++){ if (Screen->ComboT[i]==type){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if FFC collides with a combo which has specific placed flag int ComboFlagCollision (int flag, ffc f){ for (int i = 0; i<176; i++){ if (Screen->ComboF[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if FFC collides with a combo which has specific inherent flag. int ComboIFlagCollision (int flag, ffc f){ for (int i = 0; i<176; i++){ if (Screen->ComboI[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if FFC collides with a combo which has specific either inherent or placed flag. int ComboAnyFlagCollision (int flag, ffc f){ for (int i = 0; i<176; i++){ if (ComboFI(i, flag)){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns TRUE if there is a collision between Lweapon and the combo on screen. bool ComboCollision (int loc, lweapon f){ if (!(f->CollDetection)) return false; int ax = (f->X)+f->HitXOffset; int ay = (f->Y)+f->HitYOffset; int bx = ax+f->HitWidth; int by = ay+f->HitHeight; int cx = ComboX(loc); int cy = ComboY(loc); int dx = ComboX(loc)+16; int dy = ComboY(loc)+16; return RectCollision( cx, cy, dx, dy, ax, ay, bx, by); } // Returns INT if Lweapon collides with a combo of specific type int ComboTypeCollision (int type, lweapon f){ for (int i=0; i<176; i++){ if (Screen->ComboT[i]==type){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if Lweapon collides with a combo which has specific placed flag int ComboFlagCollision (int flag, lweapon f){ for (int i = 0; i<176; i++){ if (Screen->ComboF[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if Lweapon collides with a combo which has specific inherent flag. int ComboIFlagCollision (int flag, lweapon f){ for (int i = 0; i<176; i++){ if (Screen->ComboI[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if Lweapon collides with a combo which has specific either inherent or placed flag. int ComboAnyFlagCollision (int flag, lweapon f){ for (int i = 0; i<176; i++){ if (ComboFI(i, flag)){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns TRUE if there is a collision between Eweapon and the combo on screen. bool ComboCollision (int loc, eweapon f){ int ax = (f->X)+(f->HitXOffset); int ay = (f->Y)+(f->HitYOffset); int bx = ax+(f->HitWidth); int by = ay+(f->HitHeight); if (!(f->CollDetection)) return false; int cx = ComboX(loc); int cy = ComboY(loc); int dx = ComboX(loc)+16; int dy = ComboY(loc)+16; return RectCollision( cx, cy, dx, dy, ax, ay, bx, by); } // Returns INT if EWeapon collides with a combo of specific type int ComboTypeCollision (int type, eweapon f){ for (int i=0; i<176; i++){ if (Screen->ComboT[i]==type){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if EWeapon collides with a combo which has specific placed flag int ComboFlagCollision (int flag, eweapon f){ for (int i = 0; i<176; i++){ if (Screen->ComboF[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if EWeapon collides with a combo which has specific inherent flag. int ComboIFlagCollision (int flag, eweapon f){ for (int i = 0; i<176; i++){ if (Screen->ComboI[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if EWeapon collides with a combo which has specific either inherent or placed flag. int ComboAnyFlagCollision (int flag, eweapon f){ for (int i = 0; i<176; i++){ if (ComboFI(i, flag)){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns TRUE if there is a collision between NPC and the combo on screen. bool ComboCollision (int loc, npc f){ int ax = (f->X)+(f->HitXOffset); int ay = (f->Y)+(f->HitYOffset); int bx = ax+(f->HitWidth); int by = ay+(f->HitHeight); if (!(f->CollDetection)) return false; int cx = ComboX(loc); int cy = ComboY(loc); int dx = ComboX(loc)+16; int dy = ComboY(loc)+16; return RectCollision( cx, cy, dx, dy, ax, ay, bx, by); } // Returns INT if NPC collides with a combo of specific type int ComboTypeCollision (int type, npc f){ for (int i=0; i<176; i++){ if (Screen->ComboT[i]==type){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if NPC collides with a combo which has specific placed flag. int ComboFlagCollision (int flag, npc f){ for (int i = 0; i<176; i++){ if (Screen->ComboF[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if NPC collides with a combo which has specific inherent flag. int ComboIFlagCollision (int flag, npc f){ for (int i = 0; i<176; i++){ if (Screen->ComboI[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } // Returns INT if NPC collides with a combo which has specific either inherent or placed flag. int ComboAnyFlagCollision (int flag, npc f){ for (int i = 0; i<176; i++){ if (ComboFI(i, flag)){ if (ComboCollision(i, f)) return i; } } return -1; } //Returns TRUE if there is a collision between the combo and dropped item. bool ComboCollision (int loc, item f){ int ax = (f->X)+(f->HitXOffset); int ay = (f->Y)+(f->HitYOffset); int bx = ax+(f->HitWidth); int by = ay+(f->HitHeight); int cx = ComboX(loc); int cy = ComboY(loc); int dx = ComboX(loc)+16; int dy = ComboY(loc)+16; return RectCollision( cx, cy, dx, dy, ax, ay, bx, by); } //Returns INT if dropped item collides with a combo of specific type int ComboTypeCollision (int type, item f){ for (int i=0; i<176; i++){ if (Screen->ComboT[i]==type){ if (ComboCollision(i, f)) return i; } } return -1; } //Returns INT if dropped item collides with a combo which has specific placed flag. int ComboFlagCollision (int flag, item f){ for (int i=0; i<176; i++){ if (Screen->ComboF[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } //Returns INT if dropped item collides with a combo which has specific inherent flag. int ComboIFlagCollision (int flag, item f){ for (int i=0; i<176; i++){ if (Screen->ComboI[i]==flag){ if (ComboCollision(i, f)) return i; } } return -1; } //Returns INT if dropped item collides with a combo which has specific either interent or placed flag. int ComboAnyFlagCollision (int flag, item f){ for (int i = 0; i<176; i++){ if (ComboFI(i, flag)){ if (ComboCollision(i, f)) return i; } } return -1; } //Link-to-Combo interaction functions // //All these functions use the so called "sensivity" which works like "Damage combo sensivity" //value in "Screen Data" window in ZQuest. //Returns TRUE if Link touches the combo. bool LinkComboCollision(int loc, int sens){ int ax = Link->X; int ay = Link->Y; int bx = (Link->X)+(Link->HitWidth); int by = (Link->Y)+(Link->HitHeight); if(!(RectCollision( ComboX(loc), ComboY(loc), (ComboX(loc)+16), (ComboY(loc)+16), ax, ay, bx, by))) return false; else if (!(Distance(CenterLinkX(), CenterLinkY(), (ComboX(loc)+8), (ComboY(loc)+8)) < (sens+8))) return false; else return true; } //Same as LinkComboCollision, but only bottom half is checked (Link "steps" on the combo). bool LinkComboStepped(int loc, int sens){ int ax = Link->X; int ay = (Link->Y)+8; int bx = (Link->X)+(Link->HitWidth); int by = (Link->Y)+((Link->HitHeight)/2); if(!(RectCollision( ComboX(loc), ComboY(loc), (ComboX(loc)+16), (ComboY(loc)+16), ax, ay, bx, by))) return false; else if (!(Distance(CenterLinkX(), CenterLinkY(), (ComboX(loc)+8), (ComboY(loc)+8)) < (sens+8))) return false; else return true; } //Returns INT if Link touches any combo of specific type. int LinkComboTypeCollision(int type, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboT[i]==type){ if (LinkComboCollision(i, sens)) return i; } } return -1; } //Returns INT if Link steps on any combo of specific type. int LinkComboTypeStepped(int type, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboT[i]==type){ if (LinkComboStepped(i, sens)) return i; } } return -1; } //Returns INT if Link touches any combo with specific placed flag. int LinkComboFlagCollision(int flag, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboF[i]==flag){ if (LinkComboCollision(i, sens)) return i; } } return -1; } //Returns INT if Link steps on any combo with specific placed flag. int LinkComboFlagStepped(int flag, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboF[i]==flag){ if (LinkComboStepped(i, sens)) return i; } } return -1; } //Returns INT if Link touches any combo with specific inherent flag. int LinkComboIFlagCollision(int flag, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboI[i]==flag){ if (LinkComboCollision(i, sens)) return i; } } return -1; } //Returns INT if Link steps on any combo with specific inherent flag. int LinkComboIFlagStepped(int flag, int sens){ for(int i = 0; i < 176; i++){ if (Screen->ComboI[i]==flag){ if (LinkComboStepped(i, sens)) return i; } } return -1; } //Returns INT if Link touches any combo with specific either inherent or placed flag. int LinkComboAnyFlagCollision(int flag, int sens){ for(int i = 0; i < 176; i++){ if (ComboFI(i, flag)){ if (LinkComboCollision(i, sens)) return i; } } return -1; } //Returns INT if Link steps on any combo with specific either inherent or placed flag. int LinkComboAnyFlagStepped(int flag, int sens){ for(int i = 0; i < 176; i++){ if (ComboFI(i, flag)){ if (LinkComboStepped(i, sens)) return i; } } return -1; } // The following set of 25 functions behaves exactly like previous functions // but has reversed order of arguments so you don`t have to remember the order of arguments. int ComboTypeCollision (ffc f, int type){ return ComboTypeCollision (type, f); } int ComboFlagCollision (ffc f, int flag){ return ComboFlagCollision (flag, f); } int ComboIFlagCollision (ffc f, int flag){ return ComboIFlagCollision (flag, f); } int ComboAnyFlagCollision (ffc f, int flag){ return ComboAnyFlagCollision (flag, f); } int ComboTypeCollision (lweapon f, int type){ return ComboTypeCollision (type, f); } int ComboFlagCollision (lweapon f, int flag){ return ComboFlagCollision (flag, f); } int ComboIFlagCollision (lweapon f, int flag){ return ComboIFlagCollision (flag, f); } int ComboAnyFlagCollision (lweapon f, int flag){ return ComboAnyFlagCollision (flag, f); } int ComboTypeCollision (eweapon f, int type){ return ComboTypeCollision (type, f); } int ComboFlagCollision (eweapon f, int flag){ return ComboFlagCollision (flag, f); } int ComboIFlagCollision (eweapon f, int flag){ return ComboIFlagCollision (flag, f); } int ComboAnyFlagCollision (eweapon f, int flag){ return ComboAnyFlagCollision (flag, f); } int ComboTypeCollision (npc f, int flag){ return ComboTypeCollision (flag, f); } int ComboFlagCollision (npc f, int flag){ return ComboFlagCollision (flag, f); } int ComboIFlagCollision (npc f, int flag){ return ComboIFlagCollision (flag, f); } int ComboAnyFlagCollision (npc f, int flag){ return ComboAnyFlagCollision (flag, f); } int ComboTypeCollision (item f, int type){ return ComboTypeCollision (type, f); } int ComboFlagCollision (item f, int flag){ return ComboFlagCollision (flag, f); } int ComboIFlagCollision (item f, int flag){ return ComboIFlagCollision (flag, f); } int ComboAnyFlagCollision (item f, int flag){ return ComboAnyFlagCollision (flag, f); } bool ComboCollision (ffc f, int loc){ return ComboCollision (loc, f); } bool ComboCollision (lweapon f, int loc){ return ComboCollision (loc, f); } bool ComboCollision (eweapon f, int loc){ return ComboCollision (loc, f); } bool ComboCollision (npc f, int loc){ return ComboCollision (loc, f); } bool ComboCollision (item f, int loc){ return ComboCollision (loc, f); }