bool CDopeFish::isNearby(CSpriteObject &theObject) { if( dynamic_cast<CPlayerBase*>(&theObject) || dynamic_cast<CSchoolFish*>(&theObject) ) { const int objX = theObject.getXMidPos(); const int objY = theObject.getYMidPos(); const int fishX = getXMidPos(); const int fishY = getYMidPos(); const int dx = objX - fishX; const int dy = objY - fishY; if( objX < fishX - CSF_DISTANCE_TO_FOLLOW || objX > fishX + CSF_DISTANCE_TO_FOLLOW ) return false; if( objY < fishY - CSF_DISTANCE_TO_FOLLOW || objY > fishY + CSF_DISTANCE_TO_FOLLOW ) return false; if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) xDirection = LEFT; else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) xDirection = RIGHT; if( dy<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) yDirection = (rand()%5) ? UP : DOWN; else if( dy>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) yDirection = (rand()%5) ? DOWN : UP; if(getActionNumber(A_DOPEFISH_SWIM)) { int absdx = (dx<0) ? -dx : dx; int absdy = (dy<0) ? -dy : dy; if( absdx < CSF_MIN_DISTANCE_TO_CHARGE && absdy < CSF_MIN_DISTANCE_TO_CHARGE ) { setAction(A_DOPEFISH_EAT); mp_processState = &CDopeFish::processEat; m_eatTimer = DOPE_EAT_TIMER; } } } return true; }
void CRay::getTouchedBy(CSpriteObject &theObject) { if( !theObject.dead && !theObject.dying ) { if(theObject.canbezapped && state == RAY_STATE_FLY ) { // Check, if it's not form the same object CVorticonSpriteObject *theObjPtr = dynamic_cast<CVorticonSpriteObject*>(&theObject); if(theObjPtr->m_type != owner.obj_type) { state = RAY_STATE_SETZAPZOT; canbezapped = false; theObject.getShotByRay(owner.obj_type); } } } }