bool Entity_DropToFloor(ServerEntity_t *eEntity) { MathVector3f_t vEnd; trace_t trGround; Math_VectorCopy(eEntity->v.origin, vEnd); vEnd[2] -= 256; trGround = Engine.Server_Move(eEntity->v.origin, eEntity->v.mins, eEntity->v.maxs, vEnd, false, eEntity); if (trGround.fraction == 1 || trGround.bAllSolid) { Engine.Con_Warning("Entity is stuck in world! (%s) (%i %i %i)\n", eEntity->v.cClassname, (int)eEntity->v.origin[0], (int)eEntity->v.origin[1], (int)eEntity->v.origin[2]); return false; } // Use SetOrigin so that it's automatically linked. Entity_SetOrigin(eEntity, trGround.endpos); Entity_AddFlags(eEntity, FL_ONGROUND); eEntity->v.groundentity = trGround.ent; return true; }
void Area_PushableTouch(ServerEntity_t *area, ServerEntity_t *other) { if (_Area_IsOnTop(other, area)) { // So the player can jump off the object. Entity_AddFlags(other, FL_ONGROUND); return; } if (area->v.flags & FL_ONGROUND) { Entity_RemoveFlags(area, FL_ONGROUND); } // Get the right player angle. float yaw = other->v.velocity.y * ((float)PL_PI) * 2 / 360; area->v.velocity.x = std::cos(yaw) * 80.0f; area->v.velocity.y = std::sin(yaw) * 80.0f; // Don't affect the height when pushing... ever. area->v.velocity.z = 0; area->v.avelocity = area->v.velocity; area->v.nextthink = area->v.ltime + 0.5f; }