public virtual void teleportPlayer(GameBase gplayer, SceneObject exit) { Player player = gplayer._ID; TransformF targetPosition; if (exit["reorientPlayer"].AsBool()) { targetPosition = exit.getTransform(); } else { targetPosition = exit.getTransform(); TransformF playerrot = player.getTransform(); targetPosition.mOrientationX = playerrot.mOrientationX; targetPosition.mOrientationY = playerrot.mOrientationY; targetPosition.mOrientationZ = playerrot.mOrientationZ; targetPosition.MAngle = playerrot.MAngle; } player.setTransform(targetPosition); Point3F playervelocity = player.getVelocity(); playervelocity = playervelocity.vectorScale(exit["exitVelocityScale"].AsFloat()); player.setVelocity(playervelocity); // Prevent the object from doing an immediate second teleport // In the case of a bidirectional teleporter player["isTeleporting"] = true.AsString(); }
public override void onImpact(ShapeBase obj, SceneObject collObj, Point3F vec, float len) { Player player = obj.getId(); TransformF p = player.getTransform() + new TransformF(vec); float speedDamageScale = len + this["speedDamageScale"].AsFloat(); //Do not confuse the player.event_damage with the PlayerData.event_damage... player.damage(0, p.GetPosition(), speedDamageScale, "Impact"); }
public static void serverCmdcarUnmountObj(GameConnection client, Player obj) { obj.unmount(); obj.setControlObject(obj); TransformF ejectpos = obj.getTransform(); ejectpos += new TransformF(0, 0, 5); obj.setTransform(ejectpos); Vehicle mvehicle = obj["mVehicle"]; Point3F ejectvel = mvehicle.getVelocity(); ejectvel += new Point3F(0, 0, 10); ejectvel = ejectvel.vectorScale(((SimDataBlock)(obj.getDataBlock()))["mass"].AsFloat()); obj.applyImpulse(ejectpos.GetPosition(), ejectvel); }
public static void serverCmdcarUnmountObj(GameConnection client, Player obj) { obj.unmount(); obj.setControlObject(obj); TransformF ejectpos = obj.getTransform(); ejectpos += new TransformF(0, 0, 5); obj.setTransform(ejectpos); Vehicle mvehicle = obj["mVehicle"]; Point3F ejectvel = mvehicle.getVelocity(); ejectvel += new Point3F(0, 0, 10); ejectvel = ejectvel.vectorScale(((SimDataBlock) (obj.getDataBlock()))["mass"].AsFloat()); obj.applyImpulse(ejectpos.GetPosition(), ejectvel); }
public override void doDismount(Player obj) { Player player = obj.getId(); Vehicle vehicle = player["mVehicle"]; if (!vehicle.isObject()) { return; } if (!player.isMounted()) { return; } Point3F vvel = vehicle.getVelocity(); VehicleData vdb = vehicle.getDataBlock(); int maxDismountSpeed = vdb["maxDismountSpeed"].AsInt(); if ((vvel.len() <= maxDismountSpeed)) //|| (forced)) { TransformF pos = player.getTransform(); TransformF rot = pos; TransformF oldpos = pos.copy(); List <Point3F> vecs = new List <Point3F> { new Point3F(-1, 0, 0), new Point3F(0, 0, 1), new Point3F(0, 0, -1), new Point3F(1, 0, 0), new Point3F(0, -1, 0), new Point3F(0, 0, 0) }; Point3F impulsevec = new Point3F(0, 0, 0); TransformF r = math.MatrixMulVector(player.getTransform(), vecs[0]); vecs[0] = r.GetPosition(); pos.mPositionX = 0; pos.mPositionY = 0; pos.mPositionZ = 0; const int numofAttempts = 5; int success = -1; for (int i = 0; i < numofAttempts; i++) { Point3F vectorscale = vecs[i].vectorScale(3); pos = oldpos + new TransformF(vectorscale); if (!player.checkDismountPoint(oldpos.GetPosition(), pos.GetPosition())) { continue; } success = i; impulsevec = vecs[i].copy(); break; } //if ((forced) && (success == -1)) if (success == -1) { pos = oldpos.copy(); } player["mountVehicle"] = false.AsString(); player.schedule("4000", "mountVehicles", "true"); player.unmount(); player.setTransform(new TransformF(pos.mPositionX, pos.mPositionY, pos.mPositionZ, rot.mOrientationX, rot.mOrientationY, rot.mOrientationZ, rot.MAngle)); Point3F velo = impulsevec.vectorScale(player["mass"].AsFloat()); velo.z = 1; player.applyImpulse(pos.GetPosition(), velo); Point3F vel = player.getVelocity(); float vec = Point3F.vectorDot(vel, vel.normalizeSafe()); if (vec > 50) { float scale = 50 / vec; player.setVelocity(vel.vectorScale(scale)); } } else { message.MessageClient(player["client"], "msgUnmount", @"\c2Cannot exit %1 while moving.", console.GetVarString(vdb + ".nameTag")); } }