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

[svn] Make mobs scatter around in melee attack. Patch provided by smellbee.
Fix Join Instance Can Enter while Encounter is in Progress. Patch provided by mknjc.

Original author: megamage
Date: 2008-10-27 08:00:33-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Object.h

    r102 r118  
    373373            GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle( obj )); 
    374374        } 
     375        void GetRandomContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const 
     376        { 
     377            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. 
     378            //let assume 12.0f is the max size for object to have 0 angle offset. 
     379            float angle_offset_ratio = 1 - object_size/12.0f; 
     380            if (angle_offset_ratio < 0.05) angle_offset_ratio = 0.05; 
     381            // 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` 
     382            GetNearPoint(obj,x,y,z,object_size,distance2dMin+(distance2dMax-distance2dMin)*rand_norm(), GetAngle( obj ) + (M_PI_2 - M_PI * rand_norm()) * angle_offset_ratio); 
     383        } 
    375384 
    376385        float GetObjectSize() const