Changeset 141 for trunk/src/game

Show
Ignore:
Timestamp:
11/19/08 13:39:50 (17 years ago)
Author:
yumileroy
Message:

[svn] Improve TargetedMovement? (TODO: let mob find "near angle" rather than "random angle").
Delete a repeated check in instance canenter().
Fix some spell targets.
Add some sunwell spell sql.
Fix Magtheridons earthquake. (TODO: need to find out why soul transfer has no effect when casted by mobs)
Let Brutallus dual wield. Enable burn (still no script effect).
Quick fix for shadowmoon valley illidan quest crash (wait for author's fix).

Original author: megamage
Date: 2008-10-31 21:42:00-05:00

Location:
trunk/src/game
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Map.cpp

    r120 r141  
    14201420bool InstanceMap::CanEnter(Player *player) 
    14211421{ 
    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()) 
    14231447    { 
    14241448        sLog.outDebug("InstanceMap::CanEnter - Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); 
    14251449        player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); 
    14261450        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    }*/ 
    14521452 
    14531453    return Map::CanEnter(player); 
  • trunk/src/game/Object.cpp

    r138 r141  
    15331533        UpdateGroundPositionZ(x,y,z); 
    15341534} 
    1535  
    1536 void WorldObject::GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const 
    1537 { 
    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  
    378378            GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle( obj )); 
    379379        } 
    380         void GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const; 
    381380 
    382381        float GetObjectSize() const 
  • trunk/src/game/Spell.cpp

    r140 r141  
    14441444 
    14451445        // area targets 
    1446                 case TARGET_AREAEFFECT_CUSTOM: 
    14471446        case TARGET_ALL_ENEMY_IN_AREA_INSTANT: 
    14481447            if(m_spellInfo->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA) 
     
    14571456            SearchAreaTarget(TagUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_FRIENDLY); 
    14581457            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; 
    14611460        case TARGET_UNIT_AREA_ENTRY: 
    14621461        { 
     
    14651464            if(lower==upper) 
    14661465            { 
    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); 
    14681468                break; 
    14691469            } 
  • trunk/src/game/SpellEffects.cpp

    r136 r141  
    19831983            return; 
    19841984        } 
    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         } 
    19991985        default: 
    20001986        { 
    20011987            // If not exist data for dest location - return 
    2002             if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) 
     1988            if(!m_targets.HasDest()) 
    20031989            { 
    20041990                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  
    6161    { 
    6262        // 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 ); 
    6464    } 
    6565    else 
     
    165165            i_destinationHolder.ResetUpdate(50); 
    166166 
    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); 
    168168 
    169169        //More distance let have better performance, less distance let have more sensitive reaction at target move. 
     
    186186 
    187187            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)) 
    189189                owner.Attack(i_target.getTarget(),true); 
    190190        } 
  • trunk/src/game/Unit.cpp

    r140 r141  
    421421    float distsq = dx*dx + dy*dy + dz*dz; 
    422422    //not sure here, or combatreach + combatreach? 
    423     float sizefactor = GetObjectSize() + obj->GetFloatValue(UNIT_FIELD_COMBATREACH); 
     423    float sizefactor = GetFloatValue(UNIT_FIELD_COMBATREACH) + obj->GetFloatValue(UNIT_FIELD_COMBATREACH); 
    424424    float maxdist = dist2compare + sizefactor; 
    425425 
    426426    return distsq < maxdist * maxdist; 
     427} 
     428 
     429void 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)); 
    427435} 
    428436 
  • trunk/src/game/Unit.h

    r136 r141  
    722722        bool canReachWithAttack(Unit *pVictim) const; 
    723723        bool IsWithinCombatDist(Unit *obj, float dist2compare) const; 
     724        void GetRandomContactPoint( const Unit* target, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const; 
    724725        uint32 m_extraAttacks; 
    725726        bool m_canDualWield;