/*宠物群攻判定*/ void Pet::attactMonsterArrange(MonsterBase *monster,double skiHrtRatio,double _cdTime,int index) { Hero *owner=heroid_to_hero(masterId); if (owner==NULL) { return; } Map_Inform *mapNow = owner->getMap(); if (mapNow==NULL) { return; } // 群体指向性技能不闪避 float hitTimes = 1.0f; int lifeHurt = 0; unsigned range = 0; bool isCrit = false; // 群攻技能不带debuff int atkNum = 0; //受攻击人数 char msg[4096] = {0}; char tempMsg[4096] = {0}; sprintf(msg, "26,2,1,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d",petdata->petskilldata[index-1].id, 1, petdata->identity, 100, 100, 100,100,0, 0, isCrit); // cout<<"It have enter here and msg is "<<msg<<endl; Nbox *box = mapNow->getBox(); if (box == NULL) { return; } Point objPt; Point tempPt; objPt = monster->getLocation(); range = petdata->petskilldata[index-1].range; if (range != 200) { range = 200; } range += 50; //比客户端放大50范围 OneScreen *neighborScrs[4] = {0}, *oneScr = NULL; box->getNeighbour(objPt, neighborScrs); set<string> tempSet; for (int i = 0; i < 4; i++) { oneScr = neighborScrs[i]; if (oneScr == NULL) { continue; } // cout<<"hero pk state is "<<owner->gethero_PK_status()<<endl; if (owner->gethero_PK_status() != PEACE_MODE) { set<string>::iterator it_id; tempSet = oneScr->heroSet; for (it_id = tempSet.begin(); it_id != tempSet.end(); it_id++) { if (!strcmp(owner->getIdentity(), (*it_id).c_str())) { // 是宠物的主人 continue; } Hero *hitedHero = heroid_to_hero(*it_id); if (hitedHero == NULL) { continue; } // 已经死亡 if (hitedHero->getLifeVal() <= 0) { cout<<"The atked hero is dead when use many atk skill"<<endl; continue; } // 无敌状态 if (hitedHero->skillBuffState & BUFF_INVINCIBLE_STATE) { cout<<"The atked hero is invinc for atk"<<endl; continue; } if (relationCheck(owner, hitedHero, mapNow) != 2) { // 不是敌人,不能攻击 cout<<"The hero is not your enemy when use many atk skill !!"<<endl; continue; } tempPt = hitedHero->getLocation(); cout<<"really distance is:"<<GET_DISTANCE(tempPt, objPt)<<endl; cout<<"can hurt range is:"<<range<<endl; if (IS_OUT_RANGE(tempPt, objPt, range)) { // 不在作用范围内 cout<<"The atked hero is out of range when use many atk skill!!"<<endl; continue; } // 群体伤害不算攻击后反弹 lifeHurt = countAttValHero(hitedHero, skiHrtRatio, 1); sprintf(tempMsg + strlen(tempMsg), ",%s,%d,%d,%d,%d,%d,%d", hitedHero->getIdentity(), JUDGE_WILL_LIFE(hitedHero, lifeHurt), hitedHero->getLifeUpperVal(), hitedHero->getMagicVal(), hitedHero->getMagicUpperVal(), lifeHurt, 0); atkNum++; proc_hero_lose_life(owner, hitedHero, lifeHurt); } } if (oneScr->monsterSet.size() != 0) { set<string>::iterator it_monId; tempSet.clear(); tempSet = oneScr->monsterSet; for (it_monId = tempSet.begin(); it_monId != tempSet.end(); it_monId++) { // cout<<"attack one mon and monId is "<<(*it_monId)<<endl; if((*it_monId).size()==0) continue; //added by benliao MonsterBase *mon = mapNow->getMonsterObj((*it_monId).c_str()); if (mon == NULL) { continue; } if (mon->getLifeVal() <= 0 || !mon->getLifeStation()) { // 怪物已经死亡 continue; } tempPt = mon->getLocation(); if (IS_OUT_RANGE(tempPt, objPt, range)) { // 不在作用范围内 continue; } if (mon->getUnEnemySta()) { // 怪物处于无敌状态 continue; } lifeHurt = countAttValMonster(mon, skiHrtRatio, 1); sprintf(tempMsg + strlen(tempMsg), ",%s,%d,%d,%d,%d,%d,%d", mon->getIdentity(), JUDGE_WILL_LIFE(mon, lifeHurt), mon->getLifeUpperVal(), 100,100, lifeHurt, 0); atkNum++; proc_mon_lose_life(owner, mon, lifeHurt); } } if (oneScr->wagonSet.size() != 0 && owner->gethero_PK_status() != PEACE_MODE) { set<string>::iterator it_wagonId; tempSet.clear(); tempSet = oneScr->wagonSet; for (it_wagonId = tempSet.begin(); it_wagonId != tempSet.end(); it_wagonId++) { cout<<"attack one wagon and wagonId is "<<(*it_wagonId)<<endl; Wagon* wagon = NULL; map<string, Wagon*>::iterator it_wagon; it_wagon = wagonInstMap.find(*it_wagonId); if (it_wagon == wagonInstMap.end()) { continue; } wagon = it_wagon->second; if (wagon == NULL) { continue; } if (wagon->getLifeVal() <= 0) { // 怪物已经死亡 continue; } Hero *wagonOwner = wagon->getOwner(); if (wagonOwner != NULL && strcmp(wagonOwner->getIdentity(), owner->getIdentity()) == 0) { // 自己的马车不能攻击 continue; } tempPt = wagon->getLocation(); if (IS_OUT_RANGE(tempPt, objPt, range)) { // 不在作用范围内 continue; } lifeHurt = wagon->getHurt(); sprintf(tempMsg + strlen(tempMsg), ",%s,%d,%d,%d,%d,%d,%d", wagon->getIdentity(), JUDGE_WILL_LIFE(wagon, lifeHurt), wagon->getLifeUpperVal(), 100, 100, lifeHurt, 0); atkNum++; proc_wagon_lose_life(owner, wagon, lifeHurt); } } if (oneScr->bottleSet.size() != 0) { set<string>::iterator it_bottleId; tempSet.clear(); tempSet = oneScr->bottleSet; for (it_bottleId = tempSet.begin(); it_bottleId != tempSet.end(); it_bottleId++) { cout<<"attack one bottle and bottleId is "<<(*it_bottleId)<<endl; Bottle *bottInst = NULL; bottInst = mapNow->getBotInst(const_cast<char*>((*it_bottleId).c_str())); if (bottInst == NULL) { continue; } if (bottInst->getLifeVal() <= 0) { // 怪物已经死亡 continue; } tempPt = bottInst->getPiexPt(); if (IS_OUT_RANGE(tempPt, objPt, range)) { // 不在作用范围内 continue; } lifeHurt = bottInst->getHurt(); sprintf(tempMsg + strlen(tempMsg), ",%s,%d,%d,%d,%d,%d,%d", bottInst->getId(), JUDGE_WILL_LIFE(bottInst, lifeHurt), bottInst->getLifeUpperVal(),100, 100, lifeHurt, 0); atkNum++; proc_bottle_lose_life(owner, bottInst, lifeHurt); } } } sprintf(msg + strlen(msg), ",%d%s",atkNum, tempMsg); send_nine_msg(owner, msg); }
static void thumbUpdateThumbnail (CompScreen *s) { int igMidPoint[2], tMidPoint[2]; int tPos[2], tmpPos[2]; float distance = 1000000; int off, oDev, tHeight; int ox1, oy1, ox2, oy2, ow, oh; const BananaValue * option_thumb_size = bananaGetOption (bananaIndex, "thumb_size", s->screenNum); float maxSize = option_thumb_size->i; double scale = 1.0; CompWindow *w; THUMB_SCREEN (s); if (ts->thumb.win == ts->pointedWin) return; if (ts->thumb.opacity > 0.0 && ts->oldThumb.opacity > 0.0) return; if (ts->thumb.win) damageThumbRegion (s, &ts->thumb); freeThumbText (s, &ts->oldThumb); ts->oldThumb = ts->thumb; ts->thumb.textData = NULL; ts->thumb.win = ts->pointedWin; ts->thumb.dock = ts->dock; if (!ts->thumb.win || !ts->dock) { ts->thumb.win = NULL; ts->thumb.dock = NULL; return; } w = ts->thumb.win; /* do we nee to scale the window down? */ if (WIN_W (w) > maxSize || WIN_H (w) > maxSize) { if (WIN_W (w) >= WIN_H (w)) scale = maxSize / WIN_W (w); else scale = maxSize / WIN_H (w); } ts->thumb.width = WIN_W (w)* scale; ts->thumb.height = WIN_H (w) * scale; ts->thumb.scale = scale; const BananaValue * option_title_enabled = bananaGetOption (bananaIndex, "title_enabled", s->screenNum); if (option_title_enabled->b) renderThumbText (s, &ts->thumb, FALSE); else freeThumbText (s, &ts->thumb); igMidPoint[0] = w->iconGeometry.x + (w->iconGeometry.width / 2); igMidPoint[1] = w->iconGeometry.y + (w->iconGeometry.height / 2); const BananaValue * option_border = bananaGetOption (bananaIndex, "border", s->screenNum); off = option_border->i; oDev = outputDeviceForPoint (s, w->iconGeometry.x + (w->iconGeometry.width / 2), w->iconGeometry.y + (w->iconGeometry.height / 2)); if (s->nOutputDev == 1 || oDev > s->nOutputDev) { ox1 = 0; oy1 = 0; ox2 = s->width; oy2 = s->height; ow = s->width; oh = s->height; } else { ox1 = s->outputDev[oDev].region.extents.x1; ox2 = s->outputDev[oDev].region.extents.x2; oy1 = s->outputDev[oDev].region.extents.y1; oy2 = s->outputDev[oDev].region.extents.y2; ow = ox2 - ox1; oh = oy2 - oy1; } tHeight = ts->thumb.height; if (ts->thumb.textData) tHeight += ts->thumb.textData->height + TEXT_DISTANCE; // failsave position tPos[0] = igMidPoint[0] - (ts->thumb.width / 2.0); if (w->iconGeometry.y - tHeight >= 0) tPos[1] = w->iconGeometry.y - tHeight; else tPos[1] = w->iconGeometry.y + w->iconGeometry.height; // above tmpPos[0] = igMidPoint[0] - (ts->thumb.width / 2.0); if (tmpPos[0] - off < ox1) tmpPos[0] = ox1 + off; if (tmpPos[0] + off + ts->thumb.width > ox2) { if (ts->thumb.width + (2 * off) <= ow) tmpPos[0] = ox2 - ts->thumb.width - off; else tmpPos[0] = ox1 + off; } tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); tmpPos[1] = WIN_Y (ts->dock) - tHeight - off; tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); if (tmpPos[1] > oy1) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // below tmpPos[1] = WIN_Y (ts->dock) + WIN_H (ts->dock) + off; tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); if (tmpPos[1] + tHeight + off < oy2 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // left tmpPos[1] = igMidPoint[1] - (tHeight / 2.0); if (tmpPos[1] - off < oy1) tmpPos[1] = oy1 + off; if (tmpPos[1] + off + tHeight > oy2) { if (tHeight + (2 * off) <= oh) tmpPos[1] = oy2 - ts->thumb.height - off; else tmpPos[1] = oy1 + off; } tMidPoint[1] = tmpPos[1] + (tHeight / 2.0); tmpPos[0] = WIN_X (ts->dock) - ts->thumb.width - off; tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); if (tmpPos[0] > ox1 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } // right tmpPos[0] = WIN_X (ts->dock) + WIN_W (ts->dock) + off; tMidPoint[0] = tmpPos[0] + (ts->thumb.width / 2.0); if (tmpPos[0] + ts->thumb.width + off < ox2 && GET_DISTANCE (igMidPoint, tMidPoint) < distance) { tPos[0] = tmpPos[0]; tPos[1] = tmpPos[1]; distance = GET_DISTANCE (igMidPoint, tMidPoint); } ts->thumb.x = tPos[0]; ts->thumb.y = tPos[1]; ts->thumb.offset = off; ts->thumb.opacity = 0.0; damageThumbRegion (s, &ts->thumb); }