本文整理汇总了C++中Hero::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::getLocation方法的具体用法?C++ Hero::getLocation怎么用?C++ Hero::getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::getLocation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: response
void MonsterActive::response(void)
{
StyObj obj(identity,MONSTER_STYLE_TYPE);
vector<string> herId;
Point heroPt;
Hero *perHero;
Nbox *box;
if(map_now == NULL)
{
return;
}
box = map_now->getBox();
if(box == NULL || !isAlive)
{
return;
}
/*判断任务是否还在*/
if(judgeTask())
{
cout<<"the task mon of the task is illeay:"<<endl;
return;
}
if(!isPlayOver())
{
// cout<<"it is playCd time:"<<endl;
return;
}
memset(otherMsg,'\0',MONSTER_MSG_LENGTH + 1);
box->getStaInSrcVec(obj);
/*处理延时性技能*/
hitedSkiFun();
/*地图没人,判断是否已眩晕*/
if(!dizz)
{
stopMove();
return;
}
/*回血功能*/
recoverBloodSelf();
/*boss逃跑*/
if(flgRun)
{
/*判断是否已定身*/
if(!skiBody)
{
stopMove();
return;
}
}
else
{
/*仇恨范围搜寻*/
schRge();
/*如果仇恨列表不为空*/
if(!enmityValues.empty())
{
/*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/
perHero = getHero(perHerId);
if(perHero == NULL || !perHero->getLifeStation())
{
return;
}
heroPt = perHero->getLogPt();
/*攻击距离判断*/
int fight_state = attackRangePoint(pt,perHero->getLocation(),attack_range);
if(fight_state != 1)
{
/*判断是否已定身*/
if(!skiBody)
{
stopMove();
return;
}
/*如果人物没动,则这次就不必要再寻一次路*/
if(jdgSmePt(heroPt))
{
findAttWay(heroPt);
isPersuitHero = true;
}
}
else
//.........这里部分代码省略.........
示例2: attactMonsterArrange
/*宠物群攻判定*/
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;
//.........这里部分代码省略.........
示例3: attactWagonComm
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;
//.........这里部分代码省略.........
示例4: attackWagon
void attackWagon(char* attackerId, int attackerCurLife, int attackerCurMagic, char* skillId, char* wagonId)
{
#if 0
Hero *attHero;
Map_Inform *map_now;
Nbox* box;
map<string,Wagon*>::iterator it_wagon;
//cout<<"BisonTest:wagonInstMap size is "<<wagonInstMap.size()<<endl;
it_wagon = wagonInstMap.find(wagonId);
if (it_wagon == wagonInstMap.end())
{
//没有这个马车
return;
}
attHero = heroid_to_hero(attackerId);
if(attHero == NULL)
{
return;
}
Wagon *wagon = it_wagon->second;
// string msg; //消息
map<string,StyObj> nbox_id_set; //马车的九宫格成员
Point wagonLocation = wagon->getLogicPt();
Point piexPt;
piexPt = attHero->getLocation();
StyObj obj(wagonId,WAGON_STYLE_TYPE);
//获取马车的九宫格,改用攻击者九宫格
map_now = attHero->getMap();
if(map_now == NULL)
{
return;
}
box = map_now->getBox();
if(box == NULL)
{
return;
}
box->getStaInSrcVec(obj);
cout<<"BisonTest: nbox size is "<<nbox_id_set.size()<<endl;
bool isLive = wagon->beAttacked();
char msg[400];
//向周围人发马车被攻击消息
// msg = "2";
// msg += intTostring(ATTACK_RETURN_SELF);
// msg += intTostring(SUCCESS);
// msg = msg + "," + skillId;
// msg = msg + "," + attackerId;
// msg += intTostring(attackerCurLife);
// msg += intTostring(attackerCurMagic);
// msg += intTostring(0);
// msg += "," + wagonId;
// msg += intTostring(wagon->getLifeVal());
// msg += intTostring(wagon->getHurt());
// msg += intTostring(0); //表明无暴击无闪避
// msg += intTostring(piexPt._x);
// msg += intTostring(piexPt._y);
sprintf(msg, "2,%d,1,%s,%s,%d,%d,0,%s,%d,%d,0,%d,%d", ATTACK_RETURN_SELF, skillId, attackerId,
attackerCurLife, attackerCurMagic, wagonId, wagon->getLifeVal(), wagon->getHurt(),
piexPt._x, piexPt._y);
box->sentBoxMsg(msg);
cout<<"BisonTest isLive value is "<<isLive<<endl;
//马车已经死亡
if (!isLive)
{
cout<<"[BisonSHow] the wagon has been distroyed!"<<endl;
//向九宫格发马车死亡消息
wagon->disperMsg();
wagonInstMap.erase(wagonInstMap.find(wagonId));
Hero *owner = wagon->getOwner();
if(owner != NULL)
{
//hero的马车没有了
strncpy(owner->memHero->wagonId, "\0", 2);
//玩家的马车任务失败
char taskId[10] = "task00295";
taskFailedDeal(owner, taskId, 1);
strncpy(taskId, "task00419", 10);
taskFailedDeal(owner, taskId, 0);
}
/* Task *task = owner->delAcceptedTaskList(taskId);
string msg = "5";
msg += intTostring(TASK_FAILED_RETURN);
msg += "," + taskId;
send_msg(owner->getFd(), msg);
if (task != NULL)
{
delete task;
} */
delete wagon;
//.........这里部分代码省略.........
示例5: redSchRge
/* 搜寻自己一个屏幕上的hero,看是不是在仇恨范围内*/
void MonsterAttRed::redSchRge(void)
{
set<string>::iterator her_it;
set<string>HeroIdSet;
list<HatVal>new_enmy;
Point heroPt;
Hero *myHero;
Nbox *box;
bool isCpy;
isCpy = false;
/*过滤仇恨列表*/
PasSchRge();
box = map_now->getBox();
if(box == NULL)
{
return;
}
box->getCentPtSrcHerIdSet(pt,HeroIdSet);
for(her_it = HeroIdSet.begin(); her_it != HeroIdSet.end(); ++her_it)
{
myHero = heroid_to_hero(*her_it);
if(myHero == NULL || myHero->getLifeStation() == DEAD || !myHero->getWalkingFlg() ||\
!myHero->getisRedName())
{
continue;
}
#if 0
if(myHero == NULL || myHero->getLifeStation() == DEAD || !myHero->getWalkingFlg())
{
continue;
}
#endif
/*为了减少误差,用像素判断*/
heroPt = myHero->getLocation();
/*判断是否在仇恨范围内*/
/*现在是以当前像素坐标点为圆心,仇恨范围动的格式做的*/
if(sqrt(pow(fabs(heroPt._x - pt._x),2)+pow(fabs(heroPt._y - pt._y),2)) < hatRge)
{
HatVal hat(const_cast<char *>((*her_it).c_str()),hatValRue->getHatInRag());
new_enmy.push_back(hat);
myHero->insertAttList(identity);
}
}
/*add by chenzhen 201301311533 */
if(!new_enmy.empty())
{
if(map_now != NULL && map_now->getFlgCpy())
{
//isCpy = true; copy and wild same. by benliao 2012.12.09
enmityValues.swap(new_enmy);
}
else
{
/*交换新仇恨列表*/
enmityValues.swap(new_enmy);
}
}
int flag;
/*这里调用一个函数,进行仇恨值列表和物品归属进行操作*/
flag = HatFun(enmityValues,new_enmy,perHerId,goodsOwner,identity,isCpy);
/*仇恨列表为空*/
if(enmityValues.empty())
{
/*把当前目标玩家至空*/
if(strlen(perHerId) != 0)
{
memset(perHerId,'\0',SHOR_MID_VALUE_LENGTH + 1);
}
/*把当前物品归属玩家至空*/
if(strlen(goodsOwner) != 0) //add chenzhen 6.8
{
memset(goodsOwner,'\0',IDL + 1);
}
return;
}
list<HatVal>::iterator hatf_it; //仇恨列表头结点(仇恨值最大)
list<HatVal>::iterator hats_it; //仇恨列表头第二结点(仇恨值第二大)
/*如果目标不为空,且目标还在仇恨范围内*/
//.........这里部分代码省略.........
示例6: response
void MonsterAttRed::response(void)
{
StyObj obj(identity,MONSTER_STYLE_TYPE);
vector<string> herId;
Point heroPt;
Hero *perHero;
Nbox *box;
if(map_now == NULL)
{
return;
}
box = map_now->getBox();
if(box == NULL || !isAlive)
{
return;
}
/*判断任务是否还在*/
if(judgeTask())
{
cout<<"the task mon of the task is illeay:"<<endl;
return;
}
if(!isPlayOver())
{
// cout<<"it is playCd time:"<<endl;
return;
}
memset(otherMsg,'\0',MONSTER_MSG_LENGTH + 1);
box->getStaInSrcVec(obj);
/*处理延时性技能*/
hitedSkiFun();
/*判断地图是否有人,怪物是否已眩晕*/
if(!dizz)
{
stopMove();
return;
}
/*回血功能*/
recoverBloodSelf();
/*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/
if(flgRun)
{
/*判断是否已定身*/
if(!skiBody)
{
stopMove();
return;
}
}
else
{
/*终究还是专打红名了 add by chenzhen 201301300950*/
redSchRge();
if(!enmityValues.empty())
{
chageEny(((*(enmityValues.begin())).id));
/*这个是从仇恨列表里面得到的最高值,至于怎么得到的,则要看仇恨计算*/
perHero = getHero(perHerId);
if(perHero == NULL || !perHero->getLifeStation())
{
return;
}
heroPt = perHero->getLogPt();
int fight_state = attackRangePoint(pt,perHero->getLocation(),attack_range);
if(fight_state != 1)
{
/*判断是否已定身*/
if(!skiBody)
{
stopMove();
return;
}
/*如果人物没动,则这次就不必要再寻一次路*/
if(jdgSmePt(heroPt))
{
findAttWay(heroPt);
isPersuitHero = true;
}
isInPatrol = false;
}
else
//.........这里部分代码省略.........