本文整理汇总了C++中ZObject类的典型用法代码示例。如果您正苦于以下问题:C++ ZObject类的具体用法?C++ ZObject怎么用?C++ ZObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ZObject类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: timeGetTime
void ZSurvival::UpdateNavMeshWeight(float fDelta)
{
// NavMesh 가중치 업데이트
if ((ZGetGame()->GetTime() - m_fLastWeightTime) >= 1.0f)
{
#ifdef _DEBUG
unsigned long int nLastTime = timeGetTime();
#endif
RNavigationMesh* pNavMesh = ZGetGame()->GetWorld()->GetBsp()->GetNavigationMesh();
if (pNavMesh != NULL)
{
pNavMesh->ClearAllNodeWeight();
ZNPCObjectMap* pNPCObjectMap = ZGetObjectManager()->GetNPCObjectMap();
for(ZNPCObjectMap::iterator i = pNPCObjectMap->begin();i!=pNPCObjectMap->end();i++)
{
ZObject* pNPCObject = i->second;
RNavigationNode* pNode = pNavMesh->FindClosestNode(pNPCObject->GetPosition());
if (pNode)
{
float fWeight = pNode->GetWeight() + 1.0f;
pNode->SetWeight(fWeight);
}
}
}
m_fLastWeightTime = ZGetGame()->GetTime();
}
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:30,代码来源:ZSurvival.cpp
示例2: GetObjectFromID
void ZBot::destroy_object_event(char *data, int size, int dummy) {
destroy_object_packet *pi = (destroy_object_packet*) data;
//good packet?
if (size < sizeof(destroy_object_packet)) {
return;
}
ZObject *obj = GetObjectFromID(pi->ref_id);
if (!obj) {
return;
}
//good packet (double check)?
if (size != sizeof(destroy_object_packet) + (sizeof(fire_missile_info) * pi->fire_missile_amount)) {
return;
}
obj->SetHealth(0, zmap);
//obj->DoDeathEffect();
for (int i = 0; i < pi->fire_missile_amount; i++) {
fire_missile_info missile_info;
memcpy((char*) &missile_info, data + sizeof(destroy_object_packet) + (sizeof(fire_missile_info) * i), sizeof(fire_missile_info));
//obj->FireTurrentMissile(missile_info.missile_x, missile_info.missile_y, missile_info.missile_offset_time);
}
//delete it?
if (pi->destroy_object) {
ZObject::RemoveObjectFromList(obj, object_list);
DeleteObjectCleanUp(obj);
}
}
开发者ID:sebhd,项目名称:zod,代码行数:35,代码来源:zbot.cpp
示例3: memset
ZObject* ZObjectManager::Pick(ZObject* pMyObject,rvector& pos,rvector& dir, RPickInfo* pInfo)
{
ZObject* pPickObject = NULL;
float best_dist = 10000.f;
RPickInfo PickInfo;
memset(&PickInfo,0,sizeof(RPickInfo));
ZObject* pObject;
for (iterator itor = begin(); itor != end(); ++itor) {
pObject = (*itor).second;
if(pObject != pMyObject) {
if(pObject->Pick(pos, dir, &PickInfo)) {
if(PickInfo.t < best_dist) {
pPickObject = pObject;
*pInfo = PickInfo;
best_dist = PickInfo.t;
}
}
}
}
return pPickObject;
}
开发者ID:Asunaya,项目名称:RefinedGunz,代码行数:29,代码来源:ZObjectManager.cpp
示例4: MStaticCast
// 초기화 할때 저항치를 계산해 둔다
void ZModule_Resistance::InitStatus()
{
m_nFR = 0;
m_nCR = 0;
m_nPR = 0;
m_nLR = 0;
// 캐릭터가 아니라면 적절한방법으로 구해놓는다
ZObject *pThisObj = MStaticCast(ZObject,m_pContainer);
ZCharacterItem *pItems = pThisObj->GetItems();
for(int i=0;i<MMCIP_END;i++)
{
ZItem *pItem = pItems->GetItem((CCMatchCharItemParts)i);
if(pItem) {
CCMatchItemDesc *pDesc = pItem->GetDesc();
if(pDesc) {
m_nFR += pDesc->m_nFR.Ref();
m_nCR += pDesc->m_nCR.Ref();
m_nLR += pDesc->m_nLR.Ref();
m_nPR += pDesc->m_nPR.Ref();
}
}
}
m_nFR = max(min(m_nFR,100),0);
m_nCR = max(min(m_nCR,100),0);
m_nPR = max(min(m_nPR,100),0);
m_nLR = max(min(m_nLR,100),0);
}
开发者ID:Kallontz,项目名称:gunz-the-tps-mmorpg,代码行数:30,代码来源:ZModule_Resistance.cpp
示例5: Update
void ZObjectManager::Update(float fDelta)
{
for (iterator itor = begin(); itor != end(); ++itor)
{
ZObject* pObject = (*itor).second;
pObject->UpdateModules(fDelta);
pObject->Update(fDelta);
}
}
开发者ID:Asunaya,项目名称:RefinedGunz,代码行数:9,代码来源:ZObjectManager.cpp
示例6: rvector
bool ZSurvival::OnPeerNPCAttackRange(MCommand* pCommand)
{
MUID uidOwner;
pCommand->GetParameter(&uidOwner, 0, MPT_UID);
MCommandParameter* pParam = pCommand->GetParameter(1);
if(pParam->GetType()!=MPT_BLOB) return false; // 문제가 있다
ZPACKEDSHOTINFO *pinfo =(ZPACKEDSHOTINFO*)pParam->GetPointer();
rvector pos = rvector(pinfo->posx,pinfo->posy,pinfo->posz);
rvector to = rvector(pinfo->tox,pinfo->toy,pinfo->toz);
// rocket 테스트로 넣어봤다.
ZObject* pOwner = ZGetGame()->m_ObjectManager.GetObject(uidOwner);
MMatchItemDesc* pDesc = NULL;
if(pOwner==NULL) return false; // 보통 치트키를 쓸경우...
if( pOwner->GetItems() )
if( pOwner->GetItems()->GetSelectedWeapon() )
pDesc = pOwner->GetItems()->GetSelectedWeapon()->GetDesc();
if (pDesc)
{
if (pDesc->m_nWeaponType.Ref() == MWT_ROCKET)
{
rvector dir = to - pos;
Normalize(dir);
ZGetGame()->m_WeaponManager.AddRocket(pos,dir,pOwner);
ZApplication::GetSoundEngine()->PlaySEFire(pDesc, pos.x, pos.y, pos.z, false);
return true;
}
else if (pDesc->m_nWeaponType.Ref() == MWT_SKILL)
{
rvector dir = to - pos;
Normalize(dir);
ZSkill skill;
skill.Init(pDesc->m_nGadgetID.Ref(), pOwner);
ZApplication::GetSoundEngine()->PlaySEFire(pDesc, pos.x, pos.y, pos.z, false);
ZGetGame()->m_WeaponManager.AddMagic(&skill, pos, dir, pOwner);
return true;
}
}
else
return false;
ZGetGame()->OnPeerShot_Range((MMatchCharItemParts)pinfo->sel_type,uidOwner,ZGetGame()->GetTime(),pos,to);
return true;
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:56,代码来源:ZSurvival.cpp
示例7: ZGetObjectManager
bool ZEffectIcon::Draw(unsigned long int nTime)
{
ZObject* pObj = ZGetObjectManager()->GetObject(m_uid);
if(pObj) {
m_Pos = pObj->GetVisualMesh()->GetHeadPosition()+rvector(0,0,60);
return ZEffectAniMesh::Draw(nTime);
}
return false;
}
开发者ID:constantinbogdan,项目名称:node3d,代码行数:10,代码来源:ZEffectAniMesh.cpp
示例8: MDynamicCast
bool ZModule_PoisonDamage::Update(float fElapsed)
{
ZObject* pObj = MDynamicCast(ZObject, m_pContainer);
if (!pObj)
_ASSERT(0);
else
{
// ������ ���� DAMAGE_DELAY
if(ZGetGame()->GetTime()>m_fNextDamageTime) {
m_fNextDamageTime+=DAMAGE_DELAY;
// ������ �ް� �ִ� ����Ʈ ������ ������ ���������� ���� ���¿����� ���δ�..
if(pObj->IsDie()) {
if( pObj->m_pVMesh->GetVisibility() < 0.5f ) {//����Ʈ�� Life Ÿ�ӵ� �����ϱ�...
m_bOnDamage = false;
return false;
}
}
else //�����������..
{
// ������� ������Ʈ�� ���⼭ �����Ϸ��������� ����� ������ �ȵ� �ϴ� �ּ�ó���Ѵ�
// 5 * (1.f-fPR) �̺κж����� zitem.xml���� damage="1"�κκ��� damage="6"�� �ϴ� ����
//float fPR = 0;
//float fDamage = 5 * (1.f-fPR) + (float)m_nDamage;
pObj->OnDamaged(m_pOwner, pObj->GetPosition(), ZD_LIGHTNING, MWT_NONE, m_fDamage, 1);
/*ZModule_HPAP *pModule = (ZModule_HPAP*)m_pContainer->GetModule(ZMID_HPAP);
if(pModule) {
pModule->OnDamage(m_pOwner,m_fDamage,1);
// pObj->OnScream();
}*/
}
}
if(ZGetGame()->GetTime()>m_fNextEffectTime) {
if(!pObj->IsDie())
{
int nEffectLevel = GetEffectLevel()+1;
m_fNextEffectTime+=EFFECT_DELAY * nEffectLevel;
ZGetEffectManager()->AddEnchantPoison2( pObj );
}
}
}
if(m_fNextDamageTime-m_fBeginTime>m_fDuration) {
m_bOnDamage = false;
return false;
}
return true;
}
开发者ID:TheChayo,项目名称:gunz-the-tps-mmorpg,代码行数:55,代码来源:ZModule_PoisonDamage.cpp
示例9:
void ZBot::CollectOurUnits_3(vector<ZObject*> &units_list, vector<ZObject*> &targeted_list) {
for (vector<ZObject*>::iterator o = ols.mobile_olist.begin(); o != ols.mobile_olist.end(); o++)
if ((*o)->GetOwner() == our_team) {
unsigned char ot, oid;
(*o)->GetObjectID(ot, oid);
//minions can't be given waypoints
if (ot == ROBOT_OBJECT && (*o)->IsMinion())
continue;
//already got a target?
if ((*o)->GetWayPointList().size()) {
int ref_id;
ZObject *tobj;
ref_id = (*o)->GetWayPointList().begin()->ref_id;
tobj = this->GetObjectFromID(ref_id);
//if we have a target skip this unit
//unless it is going to a flag we own
if (tobj) {
unsigned char tot, toid;
tobj->GetObjectID(tot, toid);
if (tot == MAP_ITEM_OBJECT && toid == FLAG_ITEM) {
if (tobj->GetOwner() != our_team) {
targeted_list.push_back(tobj);
continue;
}
} else {
//do not flag a repair station as "targeted"
//(and therefor to be possibly ignored)
if (!(tot == BUILDING_OBJECT && toid == REPAIR))
targeted_list.push_back(tobj);
continue;
}
}
//if this is a dodge wp then let the unit be
if ((*o)->GetWayPointList().begin()->mode == DODGE_WP)
continue;
}
units_list.push_back(*o);
}
}
开发者ID:sebhd,项目名称:zod,代码行数:49,代码来源:zbot.cpp
示例10: Pick
ZObject* ZObjectManager::Pick( rvector& pos, float Radius )
{
ZObject* pPickObject = NULL;
ZObject* pObject = NULL;
float best_dist = Radius;
for( iterator iter = begin(); iter != end(); ++iter )
{
pObject = iter->second;
auto vec = pObject->GetPosition() - pos;
if (Magnitude(vec) < best_dist)
{
pPickObject = pObject;
}
}
return pPickObject;
}
开发者ID:Asunaya,项目名称:RefinedGunz,代码行数:18,代码来源:ZObjectManager.cpp
示例11: ProcessNewObject
void ZBot::add_new_object_event(char *data, int size, int dummy) {
ZObject *obj = ProcessNewObject(data, size);
if (!obj)
return;
//add to short flag list?
unsigned char ot, oid;
obj->GetObjectID(ot, oid);
if (ot == MAP_ITEM_OBJECT) {
if (oid == FLAG_ITEM || oid == GRENADES_ITEM)
flag_object_list.push_back(obj);
else {
//we don't care about the rest of the map object garbage
ols.DeleteObject(obj);
}
}
}
开发者ID:sebhd,项目名称:zod,代码行数:21,代码来源:zbot.cpp
示例12: replace_building_event
void ZServer::replace_building_event(ZServer *p, char *data, int size, int player) {
start_building_packet *pi = (start_building_packet*) data;
ZObject *obj;
//good packet?
if (size != sizeof(start_building_packet))
return;
obj = p->GetObjectFromID(pi->ref_id, p->object_list);
if (!obj)
return;
//is this a building that can build?
if (!obj->ProducesUnits())
return;
//unsigned char ot, oid;
//obj->GetObjectID(ot, oid);
//if(ot != BUILDING_OBJECT) return;
//if(!(oid == FORT_FRONT || oid == FORT_BACK || oid == ROBOT_FACTORY || oid == VEHICLE_FACTORY)) return;
//is the team business kosher?
if (obj->GetOwner() == NULL_TEAM)
return;
if (p->player_info[player].team != obj->GetOwner())
return;
//logged in?
//if(p->psettings.require_login && !p->player_info[player].logged_in)
if (p->LoginCheckDenied(player)) {
p->SendNews(player, "start production error: login required, please type /help", 0, 0, 0);
return;
}
//ignored?
if (p->player_info[player].ignored) {
p->SendNews(player, "start production error: player currently ignored", 0, 0, 0);
return;
}
// Cancel current production:
obj->StopBuildingProduction();
//ok it is a building that can build so lets set its new production
if (obj->SetBuildingProduction(pi->ot, pi->oid)) {
//now let us tell everyone the building's new state
p->RelayBuildingState(obj);
//tell the person who did it
computer_msg_packet send_data;
send_data.ref_id = obj->GetRefID();
send_data.sound = COMP_STARTING_MANUFACTURE_SND;
p->server_socket.SendMessage(player, COMP_MSG, (char*) &send_data, sizeof(computer_msg_packet));
}
}
开发者ID:sebhd,项目名称:zod,代码行数:55,代码来源:zserver_events.cpp
示例13: cancel_building_queue_event
void ZServer::cancel_building_queue_event(ZServer *p, char *data, int size, int player) {
cancel_building_queue_packet *pi = (cancel_building_queue_packet*) data;
ZObject *obj;
//good packet?
if (size != sizeof(cancel_building_queue_packet))
return;
obj = p->GetObjectFromID(pi->ref_id, p->object_list);
if (!obj)
return;
//is the team business kosher?
if (obj->GetOwner() == NULL_TEAM)
return;
if (p->player_info[player].team != obj->GetOwner())
return;
//produces units?
if (!obj->ProducesUnits())
return;
//logged in?
if (p->LoginCheckDenied(player)) {
p->SendNews(player, "cancel queue error: login required, please type /help", 0, 0, 0);
return;
}
//ignored?
if (p->player_info[player].ignored) {
p->SendNews(player, "cancel queue error: player currently ignored", 0, 0, 0);
return;
}
if (obj->CancelBuildingQueue(pi->list_i, pi->ot, pi->oid))
p->RelayObjectBuildingQueue(obj);
}
开发者ID:sebhd,项目名称:zod,代码行数:38,代码来源:zserver_events.cpp
示例14: Draw
void ZObjectManager::Draw()
{
m_nRenderedCnt = 0;
m_nOnDrawCnt = 0;
ZObject* pMyCharacter = (ZObject*)g_pGame->m_pMyCharacter;
for (iterator itor = begin(); itor != end(); ++itor)
{
ZObject* pObject = (*itor).second;
if (pObject == NULL) continue;
if (pObject == pMyCharacter) continue;
DrawObject(pObject);
}
if( pMyCharacter )
{
RVisualMesh* pVMesh = pMyCharacter->GetVisualMesh();
if(pVMesh) {
if(pVMesh->GetVisibility() != 1.f) {
pVMesh->SetSpRenderMode(1);
DrawObject( pMyCharacter );
pVMesh->SetSpRenderMode(2);
}
pMyCharacter->m_bRendered = DrawObject( pMyCharacter );
pVMesh->SetSpRenderMode(0);
}
}
}
开发者ID:Asunaya,项目名称:RefinedGunz,代码行数:38,代码来源:ZObjectManager.cpp
示例15: ZGetGame
bool ZEffectDash::Draw(unsigned long int nTime)
{
ZObject *pTarget = ZGetGame()->m_ObjectManager.GetObject(m_uid);
if(pTarget) {
ZObserver *pObserver = ZGetGameInterface()->GetCombatInterface()->GetObserver();
if(pObserver->IsVisible())
{
rvector pos,dir;
pTarget->GetHistory(&pos,&dir,ZGetGame()->GetTime()-pObserver->GetDelay());
m_Pos = pos;
} else
m_Pos = pTarget->GetPosition();
return ZEffectAniMesh::Draw(nTime);
}
/*
if(m_pObj) {
m_Pos = m_pObj->GetPosition();
}
return ZEffectSlash::Draw(nTime);
*/
return false;
}
开发者ID:constantinbogdan,项目名称:node3d,代码行数:24,代码来源:ZEffectAniMesh.cpp
示例16: add_building_queue_event
void ZServer::add_building_queue_event(ZServer *p, char *data, int size, int player) {
add_building_queue_packet *pi = (add_building_queue_packet*) data;
ZObject *obj;
//good packet?
if (size != sizeof(add_building_queue_packet))
return;
obj = p->GetObjectFromID(pi->ref_id, p->object_list);
if (!obj)
return;
//printf("add queue %d %d\n", pi->ot, pi->oid);
//is the team business kosher?
if (obj->GetOwner() == NULL_TEAM)
return;
if (p->player_info[player].team != obj->GetOwner())
return;
//produces units?
if (!obj->ProducesUnits())
return;
//logged in?
if (p->LoginCheckDenied(player)) {
p->SendNews(player, "add queue error: login required, please type /help", 0, 0, 0);
return;
}
//ignored?
if (p->player_info[player].ignored) {
p->SendNews(player, "add queue error: player currently ignored", 0, 0, 0);
return;
}
//are we starting production or adding to the queue?
unsigned char bot, boid;
if (obj->GetBuildUnit(bot, boid) && bot == (unsigned char) -1 && boid == (unsigned char) -1) {
if (obj->SetBuildingProduction(pi->ot, pi->oid))
p->RelayBuildingState(obj);
} else {
if (obj->AddBuildingQueue(pi->ot, pi->oid))
p->RelayObjectBuildingQueue(obj);
}
}
开发者ID:sebhd,项目名称:zod,代码行数:47,代码来源:zserver_events.cpp
示例17: MUID
bool ZBrain::GetUseableSkill( int *pnSkill, MUID *puidTarget, rvector *pTargetPosition)
{
// Get skill module
ZModule_Skills *pmod = (ZModule_Skills *)m_pBody->GetModule(ZMID_SKILLS);
if ( !pmod)
return false;
// Set value
if ( puidTarget)
(*puidTarget) = MUID(0,0);
if (pTargetPosition)
(*pTargetPosition) = rvector(0.0f,0.0f,0.0f);
// Check skills
for ( int i = 0; i < pmod->GetSkillCount(); i++)
{
ZSkill *pSkill = pmod->GetSkill( i);
// Check cool time
if ( !pSkill->IsReady())
continue;
// Get skill description
ZSkillDesc *pDesc = pmod->GetSkill( i)->GetDesc();
// 스킬의 적용 대상이 아군인 경우...
if ( pDesc->IsAlliedTarget())
{
// 효과가 있는 대상중 가까이 있는 걸 찾는다.
float fDist = DIST_OUT;
ZObject *pAlliedTarget = NULL;
for ( ZObjectManager::iterator itor = ZGetObjectManager()->begin(); itor != ZGetObjectManager()->end(); ++itor)
{
ZObject *pObject = itor->second;
// 죽은 놈은 넘어간다
if ( pObject->IsDie())
continue;
// 적이면 넘어간다
if ( ZGetGame()->CanAttack(m_pBody,pObject))
continue;
// 자기 자신이면 넘어간다
if ( pObject == m_pBody)
continue;
// Get distance
float dist = MagnitudeSq( pObject->GetPosition() - m_pBody->GetPosition());
if ( pSkill->IsUsable( pObject) && ( dist < fDist))
{
fDist = dist;
pAlliedTarget = pObject;
}
}
// 만약 대상이 없으면 자기 자신한테라도 스킬을 건다.
if ( ( pAlliedTarget == NULL) && ( pSkill->IsUsable( m_pBody)))
pAlliedTarget = m_pBody;
if (pAlliedTarget)
{
if ( pnSkill)
*pnSkill = i;
if ( puidTarget)
*puidTarget = pAlliedTarget->GetUID();
if ( pTargetPosition)
*pTargetPosition = pAlliedTarget->GetCenterPos();
return true;
}
}
// 스킬의 적용 대상이 적군인 경우...
else
{
ZObject* pTarget = GetTarget();
if ( pTarget == NULL)
continue;
// Check useable
if ( !pSkill->IsUsable( pTarget))
continue;
// Get pick info
ZPICKINFO pickinfo;
memset( &pickinfo, 0, sizeof( ZPICKINFO));
// Check picking
rvector pos, tarpos, dir;
// 적과 나의 몸통 실린더에서 가슴 정도의 높이 지점끼리 피킹 쏴본다..
//.........这里部分代码省略.........
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:101,代码来源:ZBrain.cpp
示例18: CheckWaypoint
bool ZCore::CheckWaypoint(ZObject *obj, waypoint *wp)
{
unsigned char ot, oid;
unsigned char aot, aoid;
ZObject *aobj;
obj->GetObjectID(ot, oid);
//just set this to false if
//the unit can not attack
if(!obj->CanAttack()) wp->attack_to = false;
switch(wp->mode)
{
case MOVE_WP:
//can move?
if(!obj->CanMove()) return false;
break;
case FORCE_MOVE_WP:
//can move?
if(!obj->CanMove()) return false;
//clients are not allowed to set forcemove waypoints
wp->mode = MOVE_WP;
break;
case DODGE_WP:
//can move?
if(!obj->CanMove()) return false;
//clients are not allowed to set dodge waypoints
wp->mode = MOVE_WP;
case AGRO_WP:
//clients are not allowed to set agro waypoints
wp->mode = ATTACK_WP;
break;
case ATTACK_WP:
//attacking an object that can only be attacked by explosions?
aobj = GetObjectFromID(wp->ref_id, object_list);
if(!aobj) return false;
if(!obj->CanAttackObject(aobj)) return false;
//if(!obj->HasExplosives() && aobj->AttackedOnlyByExplosives()) return false;
//if(!obj->CanAttack()) return false;
break;
case ENTER_WP:
//can move?
if(!obj->CanMove()) return false;
//entering ok?
if(ot != ROBOT_OBJECT) return false;
//target exist?
aobj = GetObjectFromID(wp->ref_id, object_list);
if(!aobj) return false;
//can the target be entered?
if(!aobj->CanBeEntered()) return false;
break;
case CRANE_REPAIR_WP:
//can move?
if(!obj->CanMove()) return false;
//it a crane?
if(!(ot == VEHICLE_OBJECT && oid == CRANE)) return false;
//target exist?
aobj = GetObjectFromID(wp->ref_id, object_list);
if(!aobj) return false;
//can it repair that target?
if(!aobj->CanBeRepairedByCrane(obj->GetOwner())) return false;
break;
case UNIT_REPAIR_WP:
//can move?
if(!obj->CanMove()) return false;
//can it be repaired?
if(!obj->CanBeRepaired()) return false;
//target exist?
aobj = GetObjectFromID(wp->ref_id, object_list);
if(!aobj) return false;
//can the target repair it?
if(!aobj->CanRepairUnit(obj->GetOwner())) return false;
break;
case ENTER_FORT_WP:
//can move?
if(!obj->CanMove()) return false;
//target exist?
aobj = GetObjectFromID(wp->ref_id, object_list);
if(!aobj) return false;
//can we enter it?
if(!aobj->CanEnterFort(obj->GetOwner())) return false;
break;
case PICKUP_GRENADES_WP:
//.........这里部分代码省略.........
开发者ID:Nitaym,项目名称:zodengine,代码行数:101,代码来源:zcore.cpp
示例19: GetTarget
void ZBrain::ProcessBuildPath( float fDelta)
{
// Update timer
if ( !m_PathFindingTimer.Update( fDelta))
return;
// Check status
ZTASK_ID nTaskID = m_pBody->m_TaskManager.GetCurrTaskID();
if ( (nTaskID == ZTID_ATTACK_MELEE) || (nTaskID == ZTID_ATTACK_RANGE) || (nTaskID == ZTID_ROTATE_TO_DIR) || (nTaskID == ZTID_SKILL))
return;
// 맵에 끼었다면 벗어난다
// 워프해서 끼임을 탈출하는 건 서바이벌일때만으로 제한한다 (워프는 눈에 크게 띄고 조악한 해결법이다. 기존 퀘스트에서 없던 몹워프가 일어나 유저 불만이 있음)
if (ZGetGameTypeManager()->IsSurvivalOnly( ZGetGame()->GetMatch()->GetMatchType()))
{
if (EscapeFromStuckIn(m_WayPointList))
return;
}
// Get target
ZObject* pTarget = GetTarget();
if ( !pTarget)
{
m_pBody->m_TaskManager.Clear();
m_pBody->Stop();
return;
}
// 원거리 공격이거나 우호적이면 넘 가까이 다가가지 않고 바라만 본다.
if ( ( m_Behavior.GetOffenseType() == ZOFFENSETYPE_RANGE) || m_Behavior.IsFriendly())
{
// 거리를 구한다.
float dist = MagnitudeSq( pTarget->GetPosition() - m_pBody->GetPosition());
bool bStop = false;
// Friendly type
if ( m_Behavior.IsFriendly())
{
if ( dist < m_fDistForcedIn)
bStop = true;
}
// Else type
else
{
// 직선 거리를 본다.
if ( ( dist > DIST_FORCEDIN) && (dist < m_fDistIn))
{
// 직선 거리는 가까운데 높이가 많이 차이가 나는지 본다.
dist = pTarget->GetPosition().z - m_pBody->GetPosition().z;
// 높이가 넘 많이 차이 안나면 정지
if ( (dist > -DIST_HEIGHT) && (dist < DIST_HEIGHT))
bStop = true;
}
}
// Stop
if ( bStop)
{
// 볼 수 있는 위치여야지 정지가 가능하다. 만약 안보인다면 뛰어가서 근접공격을 하도록 한다
if ( m_pBody->CanSee( pTarget) && m_pBody->CanAttackRange( pTarget))
{
m_pBody->Stop();
m_pBody->m_TaskManager.Clear();
return;
}
}
}
// Make path
RNavigationMesh* pNavMesh = ZGetGame()->GetWorld()->GetBsp()->GetNavigationMesh();
if ( pNavMesh == NULL)
return;
// Make navigation path
rvector tarpos = pTarget->GetPosition();
if ( !pNavMesh->BuildNavigationPath( m_pBody->GetPosition(), tarpos))
return;
m_WayPointList.clear();
for ( list<rvector>::iterator itor = pNavMesh->GetWaypointList().begin(); itor != pNavMesh->GetWaypointList().end(); ++itor)
m_WayPointList.push_back( (*itor));
AdjustWayPointWithBound(m_WayPointList, pNavMesh);
PushWayPointsToTask();
}
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:93,代码来源:ZBrain.cpp
注:本文中的ZObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论