public void AudioServerPlay3D(string profile, TransformF transform) { foreach (coGameConnection clientid in ClientGroup) { clientid.play3D(profile, transform); } }
/// <summary> /// /// </summary> /// <returns></returns> public TransformF copy() { TransformF t = new TransformF(mPosition.x, mPosition.y, mPosition.z, mOrientation.x, mOrientation.y, mOrientation.z, MAngle); return(t); }
public bool TeleporterTriggerVerifyObject(string thisobj, string obj, string entrance, string exit) { // Bail out early if we couldn't find an exit for this teleporter. if (!console.isObject(exit)) { console.error(string.Format("Cound not find an exit for {0}", console.GetVarString(entrance + ".name"))); return false; } if (!SimObject.SimObject_isMemberOfClass(obj, "Player")) return false; // If the entrance is once sided, make sure the object // approached it from it's front. if (console.GetVarBool(string.Format("{0}.oneSided", entrance))) { TransformF forwardvector = new TransformF(SceneObject.getForwardVector(entrance)); Point3F velocity = ShapeBase.getVelocity(obj); float dotProduct = TransformF.vectorDot(forwardvector, velocity); if (dotProduct > 0) return false; // If we are coming directly from another teleporter and it happens // to be bidirectional, We need to avoid ending sending objects through // an infinite loop. if (console.GetVarBool(string.Format("{0}.isTeleporting", obj))) return false; // We only want to teleport players // So bail out early if we have found any // other object. if (console.GetVarInt(string.Format("{0}.timeOfLastTeleport", entrance)) > 0 && console.GetVarInt(string.Format("{0}.teleporterCooldown", entrance)) > 0) { int currentTime = console.getSimTime(); int timedifference = currentTime - console.GetVarInt(string.Format("{0}.timeOfLastTeleport", entrance)); uint db = console.getDatablock(entrance); if (timedifference <= console.GetVarInt(string.Format("{0}.teleporterCooldown", db.AsString()))) return false; } } return true; }
public void WeaponImageonWetFire(string thisobj, string obj, string slot) { if (!console.isObject(thisobj + ".projectile")) { console.error("WeaponImage::onFire() - Invalid projectile datablock"); return; } // Decrement inventory ammo. The image's ammo state is updated // automatically by the ammo inventory hooks. if (!console.GetVarBool(string.Format("{0}.infiniteAmmo", thisobj))) ShapeBaseShapeBaseDecInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj)), "1"); // Get the player's velocity, we'll then add it to that of the projectile int numProjectiles = console.GetVarInt(string.Format("{0}.projectileNum", thisobj)); if (numProjectiles == 0) numProjectiles = 1; TransformF muzzleVector = new TransformF(); for (int i = 0; i < numProjectiles; i++) { if (console.GetVarBool(string.Format("{0}.wetProjectileSpread", thisobj))) { // We'll need to "skew" this projectile a little bit. We start by // getting the straight ahead aiming point of the gun Point3F vec = ShapeBase.getMuzzleVector(obj, slot.AsInt()); // Then we'll create a spread matrix by randomly generating x, y, and z // points in a circle Random r = new Random(); TransformF matrix = new TransformF(); matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj))); matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj))); matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj))); TransformF mat = math.MatrixCreateFromEuler(matrix); muzzleVector = math.MatrixMulVector(mat, vec); } else { muzzleVector = new TransformF(ShapeBase.getMuzzleVector(obj, slot.AsInt())); } Point3F objectVelocity = ShapeBase.getVelocity(obj); muzzleVector = muzzleVector.vectorScale(console.GetVarFloat(string.Format("{0}.wetProjectile.muzzleVelocity", thisobj))); objectVelocity = objectVelocity.vectorScale(console.GetVarFloat(string.Format("{0}.wetProjectile.velInheritFactor", thisobj))); Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity; Torque_Class_Helper tch = new Torque_Class_Helper(console.GetVarString(string.Format("{0}.projectileType", thisobj)), ""); tch.Props.Add("dataBlock", console.GetVarString(string.Format("{0}.wetProjectile", thisobj))); tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"'); tch.Props.Add("initialPosition", '"' + ShapeBase.getMuzzlePoint(obj, slot.AsInt()).ToString() + '"'); tch.Props.Add("sourceObject", obj); tch.Props.Add("sourceSlot", slot); tch.Props.Add("client", console.GetVarString(string.Format("{0}.client", obj))); tch.Props.Add("sourceClass", console.GetClassName(obj)); string project = tch.Create(m_ts).ToString(CultureInfo.InvariantCulture); SimSet.pushToBack("MissionCleanup", project); } }
/// <summary> /// Set the camera to orbit around a given point. /// @param orbitPoint The point to orbit around. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform(). /// @param minDistance The minimum distance allowed to the orbit object or point. /// @param maxDistance The maximum distance allowed from the orbit object or point. /// @param initDistance The initial distance from the orbit object or point. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @param locked [optional] Indicates the camera does not receive input from the player. Default is false. /// @see Camera::setOrbitMode()) /// /// </summary> public void setOrbitPoint(string camera, TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, Point3F offset, bool xlocked){ m_ts.fnCamera_setOrbitPoint(camera, orbitPoint.AsString(), minDistance, maxDistance, initDistance, offset.AsString(), xlocked); }
/// <summary> /// @brief Multiply the vector by the transform assuming that w=0. /// This function will multiply the given vector by the given transform such that translation will /// not affect the vector. /// @param transform A transform. /// @param vector A vector. /// @return The transformed vector. /// @ingroup Matrices) /// /// </summary> public Point3F MatrixMulVector(TransformF transform, Point3F vector){ return new Point3F ( m_ts.fn_MatrixMulVector(transform.AsString(), vector.AsString())); }
/// <summary> /// @brief Multiply the given point by the given transform assuming that w=1. /// This function will multiply the given vector such that translation with take effect. /// @param transform A transform. /// @param point A vector. /// @return The transformed vector. /// @ingroup Matrices) /// /// </summary> public Point3F MatrixMulPoint(TransformF transform, Point3F point){ return new Point3F ( m_ts.fn_MatrixMulPoint(transform.AsString(), point.AsString())); }
/// <summary> /// Set the object's transform (orientation and position). /// @param txfm object transform to set ) /// /// </summary> public void setTransform(string sceneobject, TransformF txfm){ m_ts.fnSceneObject_setTransform(sceneobject, txfm.AsString()); }
public string RocketLauncherImageOnAltFire(string thisobj, string obj, string slot) { string currentAmmo = ShapeBaseShapeBaseGetInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj))).AsString(); if (currentAmmo.AsInt() < console.GetVarInt(string.Format("{0}.loadCount", thisobj))) console.SetVar(string.Format("{0}.loadCount", thisobj), currentAmmo); string project = ""; for (int shotCount = 0; shotCount < console.GetVarInt(string.Format("{0}.loadCount", thisobj)); shotCount++) { // Decrement inventory ammo. The image's ammo state is updated // automatically by the ammo inventory hooks. ShapeBaseShapeBaseDecInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj)), "1"); // We fire our weapon using the straight ahead aiming point of the gun // We'll need to "skew" the projectile a little bit. We start by getting // the straight ahead aiming point of the gun Point3F vec = ShapeBase.getMuzzleVector(obj, slot.AsInt()); Random r = new Random(); TransformF matrix = new TransformF(); matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); TransformF mat = math.MatrixCreateFromEuler(matrix); // Which we'll use to alter the projectile's initial vector with TransformF muzzleVector = math.MatrixMulVector(mat, vec); // Get the player's velocity, we'll then add it to that of the projectile TransformF objectVelocity = new TransformF(ShapeBase.getVelocity(obj)); muzzleVector = muzzleVector.vectorScale(console.GetVarFloat(string.Format("{0}.projectile.muzzleVelocity", thisobj))); objectVelocity = objectVelocity.vectorScale(console.GetVarFloat(string.Format("{0}.projectile.velInheritFactor", thisobj))); TransformF muzzleVelocity = muzzleVector + objectVelocity; Torque_Class_Helper tch = new Torque_Class_Helper(console.GetVarString(string.Format("{0}.projectileType", thisobj)), ""); tch.Props.Add("dataBlock", console.GetVarString(string.Format("{0}.projectile", thisobj))); tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"'); tch.Props.Add("initialPosition", '"' + ShapeBase.getMuzzlePoint(obj, slot.AsInt()).ToString() + '"'); tch.Props.Add("sourceObject", obj); tch.Props.Add("sourceSlot", slot); tch.Props.Add("client", console.GetVarString(string.Format("{0}.client", obj))); project = tch.Create(m_ts).ToString(CultureInfo.InvariantCulture); SimSet.pushToBack("MissionCleanup", project); } return project; }
public static TransformF vectorScale(TransformF point, float scalar) { return point*scalar; }
public static float vectorDot(TransformF p1, Point3F p2) { return (p1.mPosition.x*p2.x + p1.mPosition.y*p2.y + p1.mPosition.z*p2.z); }
public TransformF copy() { TransformF t = new TransformF(mPosition.x, mPosition.y, mPosition.z, mOrientation.x, mOrientation.y, mOrientation.z, MAngle); return t; }
public string RocketLauncherImageOnAltFire(coItem thisobj, coPlayer obj, string slot) { int currentAmmo = ShapeBaseShapeBaseGetInventory(obj, (thisobj["ammo"])); if (currentAmmo < thisobj["loadCount"].AsInt()) thisobj["loadCount"] = currentAmmo.AsString(); coProjectile projectile = null; for (int shotCount = 0; shotCount < thisobj["loadCount"].AsInt(); shotCount++) { // Decrement inventory ammo. The image's ammo state is updated // automatically by the ammo inventory hooks. ShapeBaseShapeBaseDecInventory(obj, (thisobj["ammo"]), 1); // We fire our weapon using the straight ahead aiming point of the gun // We'll need to "skew" the projectile a little bit. We start by getting // the straight ahead aiming point of the gun Point3F vec = obj.getMuzzleVector(slot.AsInt()); Random r = new Random(); TransformF matrix = new TransformF(); matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008); TransformF mat = math.MatrixCreateFromEuler(matrix); // Which we'll use to alter the projectile's initial vector with TransformF muzzleVector = math.MatrixMulVector(mat, vec); // Get the player's velocity, we'll then add it to that of the projectile TransformF objectVelocity = new TransformF(obj.getVelocity()); muzzleVector = muzzleVector.vectorScale(thisobj["projectile.muzzleVelocity"].AsFloat()); objectVelocity = objectVelocity.vectorScale(thisobj["projectile.velInheritFactor"].AsFloat()); TransformF muzzleVelocity = muzzleVector + objectVelocity; Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"], ""); tch.Props.Add("dataBlock", thisobj["projectile"]); tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"'); tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot.AsInt()).AsString() + '"'); tch.Props.Add("sourceObject", obj); tch.Props.Add("sourceSlot", slot); tch.Props.Add("client", obj["client"]); projectile = tch.Create(); ((coSimSet) "MissionCleanup").pushToBack(projectile); } return projectile; }
/// <summary> /// Normal, Linear), /// @brief Adds a new knot to the front of a path camera's path. /// @param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform() /// @param speed Speed setting for this knot. /// @param type Knot type (Normal, Position Only, Kink). /// @param path %Path type (Linear, Spline). /// @tsexample /// // Transform vector for new knot. (Pos_X,Pos_Y,Pos_Z,Rot_X,Rot_Y,Rot_Z,Angle) /// %transform = \"15.0 5.0 5.0 1.4 1.0 0.2 1.0\" /// // Speed setting for knot. /// %speed = \"1.0\"; /// // Knot type. (Normal, Position Only, Kink) /// %type = \"Normal\"; /// // Path Type. (Linear, Spline) /// %path = \"Linear\"; /// // Inform the path camera to add a new knot to the front of its path /// %pathCamera.pushFront(%transform, %speed, %type, %path); /// @endtsexample) /// /// </summary> public void pushFront(TransformF transform, float speed, string type, string path) { TorqueScriptTemplate.m_ts.fnPathCamera_pushFront(_mSimObjectId, transform.AsString(), speed, type, path); }
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> public static float vectorDot(TransformF p1, Point3F p2) { return(p1.mPosition.x * p2.x + p1.mPosition.y * p2.y + p1.mPosition.z * p2.z); }
public string ShapeBaseTossPatch(coShapeBase thisobj) { if (!thisobj.isObject()) return string.Empty; coItem item = console.Call_Classname("ItemData", "CreateItem", new[] {"HealthKitPatch"}); item["istemp"] = true.AsString(); item["sourceObject"] = thisobj; item["static"] = false.AsString(); (( coSimSet)"MissionCleanup").pushToBack(item); Random r = new Random(); Point3F vec = new Point3F(-1 + (float) r.NextDouble()*2, -1*(float) r.NextDouble()*2, (float) r.NextDouble()); vec = vec.vecotrScale(10); Point3F eye = thisobj.getEyeVector(); float dot = new Point3F("0 0 1 ").vectorDot(eye); if (dot < 0) dot = -dot; vec = vec + new Point3F("0 0 8").vecotrScale(1 - dot); vec = vec + thisobj.getVelocity(); TransformF pos = new TransformF(thisobj.getWorldBox().minExtents); item.setTransform(pos); item.applyImpulse(pos.MPosition, vec); item.setCollisionTimeout(thisobj); item.call("schedulePop"); return item; }
public void ServerCmdflipCar(coGameConnection client) { coPlayer player = client["player"]; coVehicle car = player.getControlObject(); if (car.getClassName() != "WheeledVehicle") return; TransformF carpos = car.getTransform(); carpos += new TransformF(0, 0, 3); car.setTransform(carpos); }
/// <summary> /// @brief Used on the server to play a 3D sound that is not attached to any object. /// /// @param profile The SFXProfile that defines the sound to play. /// @param location The position and orientation of the 3D sound given in the form of \"x y z ax ay az aa\". /// /// @tsexample /// function ServerPlay3D(%profile,%transform) /// { /// // Play the given sound profile at the given position on every client /// // The sound will be transmitted as an event, not attached to any object. /// for(%idx = 0; %idx ClientGroup.getCount(); %idx++) /// ClientGroup.getObject(%idx).play3D(%profile,%transform); /// } /// @endtsexample) /// /// </summary> public bool play3D(string profile, TransformF location) { return TorqueScriptTemplate.m_ts.fnGameConnection_play3D(_mSimObjectId, profile, location.AsString()); }
/// <summary> /// @brief Check if there is the space at the given transform is free to spawn into. /// /// The shape's bounding box volume is used to check for collisions at the given world /// transform. Only interior and static objects are checked for collision. /// /// @param txfm Deploy transform to check /// @return True if the space is free, false if there is already something in /// the way. /// /// @note This is a server side only check, and is not actually limited to spawning.) /// /// </summary> public bool checkDeployPos(string shapebasedata, TransformF txfm){ return m_ts.fnShapeBaseData_checkDeployPos(shapebasedata, txfm.AsString()); }
/// <summary> /// @brief Mount objB to this object at the desired slot with optional transform. /// /// @param objB Object to mount onto us /// @param slot Mount slot ID /// @param txfm (optional) mount offset transform /// @return true if successful, false if failed (objB is not valid) ) /// /// </summary> public bool mountObject(string objB, int slot, TransformF txfm) { return TorqueScriptTemplate.m_ts.fnSceneObject_mountObject(_mSimObjectId, objB, slot, txfm.AsString()); }
/// <summary> /// @brief Multiply the two matrices. /// @param left First transform. /// @param right Right transform. /// @return Concatenation of the two transforms. /// @ingroup Matrices ) /// /// </summary> public TransformF MatrixMultiply(TransformF left, TransformF right){ return new TransformF ( m_ts.fn_MatrixMultiply(left.AsString(), right.AsString())); }
/// <summary> /// Set the object's transform (orientation and position). /// @param txfm object transform to set ) /// /// </summary> public void setTransform(TransformF txfm) { TorqueScriptTemplate.m_ts.fnSceneObject_setTransform(_mSimObjectId, txfm.AsString()); }
/// <summary> /// Set the camera to orbit around the given object, or if none is given, around the given point. /// @param orbitObject The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead /// @param orbitPoint The point to orbit around when no object is given. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform(). /// @param minDistance The minimum distance allowed to the orbit object or point. /// @param maxDistance The maximum distance allowed from the orbit object or point. /// @param initDistance The initial distance from the orbit object or point. /// @param ownClientObj [optional] Are we orbiting an object that is owned by us? Default is false. /// @param offset [optional] An offset added to the camera's position. Default is no offset. /// @param locked [optional] Indicates the camera does not receive input from the player. Default is false. /// @see Camera::setOrbitObject() /// @see Camera::setOrbitPoint()) /// /// </summary> public void setOrbitMode(string camera, string orbitObject, TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, bool ownClientObj, Point3F offset, bool xlocked){ m_ts.fnCamera_setOrbitMode(camera, orbitObject, orbitPoint.AsString(), minDistance, maxDistance, initDistance, ownClientObj, offset.AsString(), xlocked); }
/// <summary> /// @brief Check if there is the space at the given transform is free to spawn into. /// /// The shape's bounding box volume is used to check for collisions at the given world /// transform. Only interior and static objects are checked for collision. /// /// @param txfm Deploy transform to check /// @return True if the space is free, false if there is already something in /// the way. /// /// @note This is a server side only check, and is not actually limited to spawning.) /// /// </summary> public bool checkDeployPos(TransformF txfm) { return TorqueScriptTemplate.m_ts.fnShapeBaseData_checkDeployPos(_mSimObjectId, txfm.AsString()); }
/// <summary> /// @brief Used on the server to play a 3D sound that is not attached to any object. /// /// @param profile The SFXProfile that defines the sound to play. /// @param location The position and orientation of the 3D sound given in the form of \"x y z ax ay az aa\". /// /// @tsexample /// function ServerPlay3D(%profile,%transform) /// { /// // Play the given sound profile at the given position on every client /// // The sound will be transmitted as an event, not attached to any object. /// for(%idx = 0; %idx < ClientGroup.getCount(); %idx++) /// ClientGroup.getObject(%idx).play3D(%profile,%transform); /// } /// @endtsexample) /// /// </summary> public bool play3D(string gameconnection, string profile, TransformF location){ return m_ts.fnGameConnection_play3D(gameconnection, profile, location.AsString()); }
public TransformF MatrixMulVector(TransformF transform, Point3F vector) { return m_ts.MathMatrixMulVector(transform, vector); }
public void ProximityMineDataDamage(coProximityMineData datablock, coProximityMine shapebase, TransformF position, coShapeBase source, string amount, string damageType) { // Explode if any damage is applied to the mine int r = 50 + (new Random().Next(0, 50)); shapebase.schedule(r.AsString(), "explode"); }
public TransformF MatrixCreateFromEuler(TransformF transform) { return m_ts.MathMatrixCreateFromEuler(transform); }
/// <summary> /// /// </summary> /// <param name="_testo"></param> /// <returns></returns> public override bool Equals(object _testo) { TransformF _test = (TransformF)_testo; return((MPosition.x == _test.MPosition.x) && (MPosition.y == _test.MPosition.y) && (MPosition.z == _test.MPosition.z)); }
/// <summary> /// Normal, Linear), /// @brief Adds a new knot to the front of a path camera's path. /// @param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform() /// @param speed Speed setting for this knot. /// @param type Knot type (Normal, Position Only, Kink). /// @param path %Path type (Linear, Spline). /// @tsexample /// // Transform vector for new knot. (Pos_X,Pos_Y,Pos_Z,Rot_X,Rot_Y,Rot_Z,Angle) /// %transform = \"15.0 5.0 5.0 1.4 1.0 0.2 1.0\" /// // Speed setting for knot. /// %speed = \"1.0\"; /// // Knot type. (Normal, Position Only, Kink) /// %type = \"Normal\"; /// // Path Type. (Linear, Spline) /// %path = \"Linear\"; /// // Inform the path camera to add a new knot to the front of its path /// %pathCamera.pushFront(%transform, %speed, %type, %path); /// @endtsexample) /// /// </summary> public void pushFront(string pathcamera, TransformF transform, float speed, string type, string path){ m_ts.fnPathCamera_pushFront(pathcamera, transform.AsString(), speed, type, path); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="scalar"></param> /// <returns></returns> public static TransformF vectorScale(TransformF point, float scalar) { return(point * scalar); }
/// <summary> /// @brief Mount objB to this object at the desired slot with optional transform. /// /// @param objB Object to mount onto us /// @param slot Mount slot ID /// @param txfm (optional) mount offset transform /// @return true if successful, false if failed (objB is not valid) ) /// /// </summary> public bool mountObject(string sceneobject, string objB, int slot, TransformF txfm){ return m_ts.fnSceneObject_mountObject(sceneobject, objB, slot, txfm.AsString()); }
public void WeaponImageonWetFire(coScriptObject thisobj, coPlayer obj, int slot) { if (!thisobj["projectile"].isObject()) { console.error("WeaponImage::onFire() - Invalid projectile datablock"); return; } // Decrement inventory ammo. The image's ammo state is updated // automatically by the ammo inventory hooks. if (!thisobj["infiniteAmmo"].AsBool()) ShapeBaseShapeBaseDecInventory(obj, thisobj["ammo"], 1); // Get the player's velocity, we'll then add it to that of the projectile int numProjectiles = thisobj["projectileNum"].AsInt(); if (numProjectiles == 0) numProjectiles = 1; TransformF muzzleVector = new TransformF(); for (int i = 0; i < numProjectiles; i++) { if (thisobj["wetProjectileSpread"].AsBool()) { // We'll need to "skew" this projectile a little bit. We start by // getting the straight ahead aiming point of the gun Point3F vec = obj.getMuzzleVector(slot); // Then we'll create a spread matrix by randomly generating x, y, and z // points in a circle Random r = new Random(); TransformF matrix = new TransformF(); matrix.MPosition.x = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat()); matrix.MPosition.y = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat()); matrix.MPosition.z = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat()); TransformF mat = math.MatrixCreateFromEuler(matrix); muzzleVector = math.MatrixMulVector(mat, vec); } else { muzzleVector = new TransformF(obj.getMuzzleVector(slot)); } Point3F objectVelocity = obj.getVelocity(); muzzleVector = muzzleVector.vectorScale(thisobj["wetProjectile.muzzleVelocity"].AsFloat()); objectVelocity = objectVelocity.vectorScale(thisobj["wetProjectile.velInheritFactor"].AsFloat()); Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity; Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"]); tch.Props.Add("dataBlock", thisobj["wetProjectile"]); tch.Props.Add("initialVelocity", '"' + muzzleVelocity.AsString() + '"'); tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot).AsString() + '"'); tch.Props.Add("sourceObject", obj); tch.Props.Add("sourceSlot", slot.AsString()); tch.Props.Add("client", obj["client"]); tch.Props.Add("sourceClass", obj.getClassName()); coItem projectile = tch.Create(); ((coSimSet)"MissionCleanup").pushToBack(projectile); } }
public void ServerCmdcarUnmountObj(coGameConnection client, coPlayer obj) { obj.unmount(); obj.setControlObject(obj); TransformF ejectpos = obj.getTransform(); ejectpos += new TransformF(0, 0, 5); obj.setTransform(ejectpos); coVehicle mvehicle = obj["mVehicle"]; Point3F ejectvel = mvehicle.getVelocity(); ejectvel += new Point3F(0, 0, 10); ejectvel = ejectvel.vectorScale(((coSimDataBlock) (obj.getDataBlock()))["mass"].AsFloat()); obj.applyImpulse(ejectpos.MPosition, ejectvel); }