Changeset 141 for trunk/src/game
- Timestamp:
- 11/19/08 13:39:50 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Map.cpp
r120 r141 1420 1420 bool InstanceMap::CanEnter(Player *player) 1421 1421 { 1422 if(!player->isGameMaster() && i_data && i_data->IsEncounterInProgress()) 1422 if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 1423 { 1424 sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); 1425 assert(false); 1426 return false; 1427 } 1428 1429 // cannot enter if the instance is full (player cap), GMs don't count 1430 InstanceTemplate const* iTemplate = objmgr.GetInstanceTemplate(GetId()); 1431 if (!player->isGameMaster() && GetPlayersCountExceptGMs() >= iTemplate->maxPlayers) 1432 { 1433 sLog.outDetail("MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), iTemplate->maxPlayers, player->GetName()); 1434 player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS); 1435 return false; 1436 } 1437 1438 // cannot enter while players in the instance are in combat 1439 Group *pGroup = player->GetGroup(); 1440 if(!player->isGameMaster() && pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->isAlive() && player->GetMapId() != GetId()) 1441 { 1442 player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); 1443 return false; 1444 } 1445 1446 /*if(!player->isGameMaster() && i_data && i_data->IsEncounterInProgress()) 1423 1447 { 1424 1448 sLog.outDebug("InstanceMap::CanEnter - Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); 1425 1449 player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); 1426 1450 return false; 1427 } 1428 1429 if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 1430 { 1431 sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); 1432 assert(false); 1433 return false; 1434 } 1435 1436 // cannot enter if the instance is full (player cap), GMs don't count 1437 InstanceTemplate const* iTemplate = objmgr.GetInstanceTemplate(GetId()); 1438 if (!player->isGameMaster() && GetPlayersCountExceptGMs() >= iTemplate->maxPlayers) 1439 { 1440 sLog.outDetail("MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), iTemplate->maxPlayers, player->GetName()); 1441 player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS); 1442 return false; 1443 } 1444 1445 // cannot enter while players in the instance are in combat 1446 Group *pGroup = player->GetGroup(); 1447 if(pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->isAlive() && player->GetMapId() != GetId()) 1448 { 1449 player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); 1450 return false; 1451 } 1451 }*/ 1452 1452 1453 1453 return Map::CanEnter(player); -
trunk/src/game/Object.cpp
r138 r141 1533 1533 UpdateGroundPositionZ(x,y,z); 1534 1534 } 1535 1536 void WorldObject::GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const1537 {1538 float object_size = obj->GetObjectSize();//here we use object_size to determine the angle offset, the bigger object the smaller angle offset, then this makes mob move naturally in visual.1539 //let assume 12.0f is the max size for object to have 0 angle offset.1540 float angle_offset_ratio = 1 - object_size/12.0f;1541 if (angle_offset_ratio < 0.05) angle_offset_ratio = 0.05;1542 // angle to face `obj` to `this`plus a random angle offset(from -90 degree to 90 degree)*angle_offset_ratio using distance from distance2dMin to distance2dMax includes size of `obj`1543 GetNearPoint(obj,x,y,z,object_size,distance2dMin+(distance2dMax-distance2dMin)*rand_norm(), GetAngle( obj ) + (M_PI/2 - M_PI * rand_norm()) * angle_offset_ratio);1544 } -
trunk/src/game/Object.h
r120 r141 378 378 GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle( obj )); 379 379 } 380 void GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const;381 380 382 381 float GetObjectSize() const -
trunk/src/game/Spell.cpp
r140 r141 1444 1444 1445 1445 // area targets 1446 case TARGET_AREAEFFECT_CUSTOM:1447 1446 case TARGET_ALL_ENEMY_IN_AREA_INSTANT: 1448 1447 if(m_spellInfo->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) … … 1457 1456 SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_FRIENDLY); 1458 1457 break; 1459 //case TARGET_AREAEFFECT_CUSTOM:1460 //m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION;1458 case TARGET_AREAEFFECT_CUSTOM: 1459 m_targets.m_targetMask |= TARGET_FLAG_DEST_LOCATION; 1461 1460 case TARGET_UNIT_AREA_ENTRY: 1462 1461 { … … 1465 1464 if(lower==upper) 1466 1465 { 1467 sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT, but does not have record in `spell_script_target`",m_spellInfo->Id); 1466 SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE); 1467 //sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT, but does not have record in `spell_script_target`",m_spellInfo->Id); 1468 1468 break; 1469 1469 } -
trunk/src/game/SpellEffects.cpp
r136 r141 1983 1983 return; 1984 1984 } 1985 case TARGET_TABLE_X_Y_Z_COORDINATES:1986 {1987 // TODO: Only players can teleport?1988 if (unitTarget->GetTypeId() != TYPEID_PLAYER)1989 return;1990 SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id);1991 if(!st)1992 {1993 sLog.outError( "Spell::EffectTeleportUnits - unknown Teleport coordinates for spell ID %u\n", m_spellInfo->Id );1994 return;1995 }1996 ((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0);1997 break;1998 }1999 1985 default: 2000 1986 { 2001 1987 // If not exist data for dest location - return 2002 if(! (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))1988 if(!m_targets.HasDest()) 2003 1989 { 2004 1990 sLog.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u\n", i, m_spellInfo->EffectImplicitTargetB[i], m_spellInfo->Id ); -
trunk/src/game/TargetedMovementGenerator.cpp
r118 r141 61 61 { 62 62 // to nearest random contact position 63 i_target->GetRandomContactPoint( &owner, x, y, z, 0.5f,4.5f );63 i_target->GetRandomContactPoint( &owner, x, y, z, 0.5f, ATTACK_DISTANCE - 0.5f ); 64 64 } 65 65 else … … 165 165 i_destinationHolder.ResetUpdate(50); 166 166 167 float dist = i_target->GetObjectSize() + owner.GetObjectSize() + sWorld.getRate(RATE_TARGET_POS_RECALCULATION_RANGE);167 float dist = owner.GetFloatValue(UNIT_FIELD_COMBATREACH) + i_target.getTarget()->GetFloatValue(UNIT_FIELD_COMBATREACH) + sWorld.getRate(RATE_TARGET_POS_RECALCULATION_RANGE); 168 168 169 169 //More distance let have better performance, less distance let have more sensitive reaction at target move. … … 186 186 187 187 owner.StopMoving(); 188 if(owner. canReachWithAttack(i_target.getTarget()) && !owner.hasUnitState(UNIT_STAT_FOLLOW))188 if(owner.IsWithinCombatDist(i_target.getTarget(), ATTACK_DISTANCE) && !owner.hasUnitState(UNIT_STAT_FOLLOW)) 189 189 owner.Attack(i_target.getTarget(),true); 190 190 } -
trunk/src/game/Unit.cpp
r140 r141 421 421 float distsq = dx*dx + dy*dy + dz*dz; 422 422 //not sure here, or combatreach + combatreach? 423 float sizefactor = Get ObjectSize() + obj->GetFloatValue(UNIT_FIELD_COMBATREACH);423 float sizefactor = GetFloatValue(UNIT_FIELD_COMBATREACH) + obj->GetFloatValue(UNIT_FIELD_COMBATREACH); 424 424 float maxdist = dist2compare + sizefactor; 425 425 426 426 return distsq < maxdist * maxdist; 427 } 428 429 void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const 430 { 431 uint32 attacker_number = getAttackers().size(); 432 if(attacker_number > 0) --attacker_number; 433 GetNearPoint(obj,x,y,z,obj->GetFloatValue(UNIT_FIELD_COMBATREACH),distance2dMin+(distance2dMax-distance2dMin)*rand_norm() 434 , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / GetFloatValue(UNIT_FIELD_COMBATREACH) / 3 : 0)); 427 435 } 428 436 -
trunk/src/game/Unit.h
r136 r141 722 722 bool canReachWithAttack(Unit *pVictim) const; 723 723 bool IsWithinCombatDist(Unit *obj, float dist2compare) const; 724 void GetRandomContactPoint( const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const; 724 725 uint32 m_extraAttacks; 725 726 bool m_canDualWield;