Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
- {
- //this function may make players fall below map
- /*if (i_owner->GetTypeId() == TYPEID_PLAYER)
- return;*/
- float x, y, z;
- float dist = speedXY * speedZ * 0.1f;
- i_owner->GetNearPoint(i_owner, x, y, z, i_owner->GetObjectSize(), dist, i_owner->GetAngle(srcX, srcY) + M_PI);
- MoveJump(x, y, z, speedXY, speedZ);
- }
- void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
- {
- Position* pos = NULL;
- // get coords before any operations
- if (searcher && searcher->GetTypeId() == TYPEID_PLAYER)
- searcher->GetPosition(pos);
- GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
- z = GetPositionZ();
- UpdateGroundPositionZ(x, y, z);
- // Use additional calculations for players
- // based on SPELL_EFFECT_LEAP code
- // IsWithinLOS(x, y, z) isn't ideal
- if (searcher && searcher->GetTypeId() == TYPEID_PLAYER && !IsWithinLOS(x, y, z))
- {
- //sLog->outError("WorldObject::GetNearPoint(start): x %f y %f z %f", x, y, z);
- float destx, desty, destz, ground, floor;
- float dist = distance2d/* + searcher_size*/;
- float orientation = absAngle, step = dist/10.0f;
- Map const* map = searcher->GetMap();
- destx = x;
- desty = y;
- destz = z;
- // if enable this - floor detection will be broken
- /*bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(searcher->GetMapId(), x1, y1, z1 + 0.5f, x, y, z + 0.5f, destx, desty, destz, -0.5f);
- if (col) // We had a collision!
- {
- destx -= 0.6 * cos(orientation);
- desty -= 0.6 * sin(orientation);
- dist = sqrt((x1-destx)*(x1-destx) + (y1-desty)*(y1-desty));
- sLog->outError("WorldObject::GetNearPoint(collision): x %f y %f dist %f", destx, desty, dist);
- }*/
- //sLog->outError("WorldObject::GetNearPoint(before cycle): x %f y %f z %f", destx, desty, destz);
- for (int j = 0; j < 10; j++)
- {
- if (!IsWithinLOS(destx, desty, destz))
- {
- destx -= step * cos(orientation);
- desty -= step * sin(orientation);
- ground = map->GetHeight(destx, desty, MAX_HEIGHT, true);
- floor = map->GetHeight(destx, desty, z, true);
- //sLog->outError("WorldObject::GetNearPoint(cycle floor z): %f", floor);
- destz = fabs(ground - z) <= fabs(floor - z) ? ground : floor;
- } else break;
- //sLog->outError("WorldObject::GetNearPoint(cycle): x %f y %f z %f", destx, desty, destz);
- }
- x = destx;
- y = desty;
- z = destz/* + 0.15f*/;
- //sLog->outError("WorldObject::GetNearPoint(new): x %f y %f z %f", x, y, z);
- if (IsWithinLOS(x, y, z))
- {
- //sLog->outError("WorldObject::GetNearPoint: new coord are in LOS!");
- // In fake LOS (thin wall or not high ground), collision detector sucks
- /*float x1, y1, z1;
- searcher->GetPosition(x1, y1, z1);
- bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(searcher->GetMapId(), x1, y1, z1 + 0.5f, x, y, z + 0.5f, x, y, z, -0.5f);
- if (col) // We had a collision!
- {
- //sLog->outError("WorldObject::GetNearPoint(before collision): x %f y %f z %f", x, y, z);
- x -= 0.6 * cos(orientation);
- y -= 0.6 * sin(orientation);
- z = map->GetHeight(x, y, z, true);
- //sLog->outError("WorldObject::GetNearPoint(collision): x %f y %f z %f", x, y, z);
- }*/
- return;
- } else
- {
- // Fail at get good coords, don't move
- x = searcher->GetPositionX();
- y = searcher->GetPositionY();
- z = searcher->GetPositionZ();
- //sLog->outError("WorldObject::GetNearPoint: new coords NOT are in LOS!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement