/*宠物群攻判定*/ 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); }
void attactWagonComm(char *buff) { #if 0 char *wagonId; //马车Id char *skillId; //使用技能的Id int index = 0; //攻击者类型 MSG_BEGIN(buff, g_msg_len); MSG_INT(index); MSG_CHAR(wagonId); MSG_CHAR_END(skillId); //由fd查hero实例 Hero *hero = pg_hero; map<string,Wagon*>::iterator it_wagon; //cout<<"BisonTest:wagonInstMap size is "<<wagonInstMap.size()<<endl; it_wagon = wagonInstMap.find(wagonId); if (it_wagon == wagonInstMap.end()) { //没有这个马车 cout<<"BisonTest: Attack failed because of no the wagon of this id "<<wagonId<<endl; return; } Wagon *wagon = it_wagon->second; Map_Inform *wagonMap = hero->getMap(); if (wagonMap == NULL) { cout<<"This Map no Id ????????????????????"<<endl; return; } char *wagonMapId = wagonMap->getIdentity(); if (strcmp(wagonMapId, "map_001") == 0) { cout<<"You can't attack wagon In This Map"<<endl; return; } char* owerId; Hero *owner = wagon->getOwner(); if (owner == NULL) { cout<<"This wagon has no owner, but you can attack it"<<endl; goto LG; //没有主人的马车也能被打 // return; } //马车主人不能打自己的马车 owerId = owner->getIdentity(); if (!strcmp(owerId, hero->getIdentity())) { return; } LG: ; //全用像素点 Point wagonLocation = wagon->getPt(); int range; //攻击者的攻击范围 //bool isLive; //马车是否还活着 int distance = 0; //攻击者离马车距离 Skill *skill; //int skillNeedMagic = 0; //技能的魔法消耗 int attackLife = 100; //攻击者当前血量……置为宠物的属性值 int attackMagic = 100; //攻击者魔法……置为宠物的属性值 //int attackHurt = wagon->getHurt(); //马车每次被攻击掉血固定 //index = 0 为人攻击马车 if (index == 0) { map<string,Skill*> attack_skill_list; //玩家角色的技能列表 map<string,Skill*>::iterator skill_iter; attack_skill_list = hero->getSkill_list(); skill_iter = attack_skill_list.find(skillId); if(skill_iter == attack_skill_list.end()) { cout<<"BisonTest: hero does not has this skill to use when attack wagon"<<endl; return; } skill = skill_iter->second; //玩家所使用的技能 if (skill->gettype() != 1 || skill->geteffect() != 1) { //管你是群攻还是医疗,只要不是主动技能都别用来搞马车 cout<<"skill type can't attack wagon"<<endl; return; } if(!isFightStatusOfHero(hero, skill)) //判断玩家的真气,和技能的时间是否符合条件 { cout<<"BisonTest: magical or time is not ok to use this skill"<<endl; return; } cout<<"BisonTest: Hero attacks the wagon "<<wagonId<<endl; //判断距离是否够 Point heroLocation = hero->getLocation(); int deltaX = wagonLocation._x - heroLocation._x; int deltaY = wagonLocation._y - heroLocation._y; int distance = sqrt(deltaX * deltaX + deltaY * deltaY); range = hero->getAtk_range(); cout<<"BisonTest: distance is "<<distance<<" hero attack range is "<<range<<endl; if (distance > range) { cout<<"BisonTest: The wagon is out attack range"<<endl; return; } else { //攻击者者扣蓝 //hero->setMagicVal(hero->getMagicVal() - skillNeedMagic); PropertyOfAttackerChange(hero, skill); //玩家的当前血蓝 attackLife = hero->getLifeVal(); //难道还有攻击者自身会掉血的情况?不懂,随着他们用 attackMagic = hero->getMagicVal(); } } else if (index == 1) { //index = 1,为宠物打马车 Pet *pet = hero->getPetBox()->getActivePet(); if (pet == NULL) { cout<<"BisonTest: hero have no active Pet "<<endl; return; } else { //宠物位置 Point petLocation = pet->getLogicNow(); petLocation = LogicalExchangeMap(petLocation); int deltaX = wagonLocation._x - petLocation._x; int deltaY = wagonLocation._y - petLocation._y; int distance = sqrt(deltaX * deltaX + deltaY * deltaY); range = pet->getAttackRange(); cout<<"BisonTest: distance is "<<distance<<" pet attack range is "<<range<<endl; if (distance > range) { cout<<"BisonTest: The wagon is out attack range"<<endl; return; } } } else { return; } attackWagon(hero->getIdentity(), attackLife, attackMagic, skillId, wagonId); #endif }