/// <summary> /// Creates Matrix from vector. /// </summary> /// <param name="transform"> </param> /// <param name="vector"> </param> /// <returns> </returns> public TransformF MathMatrixMulVector(TransformF transform, Point3F vector) { float x = transform.mPositionX; float y = transform.mPositionY; float z = transform.mPositionZ; float ang = transform.MAngle; float ax = transform.mOrientationX; float ay = transform.mOrientationY; float az = transform.mOrientationZ; float xx = vector.x; float yy = vector.y; float zz = vector.z; StringBuilder ret = new StringBuilder(1024); SafeNativeMethods.mMath_MatrixMulVector(x, y, z, ang, ax, ay, az, xx, yy, zz, ret); TransformF r = new TransformF(ret.ToString()); return(r); }
static public void AudioServerPlay3D(string profile, TransformF transform) { foreach (GameConnection clientid in tst.ClientGroup) { clientid.play3D(profile, transform); } }
public void TeleporterTriggerTeleportPlayer(coSimDataBlock thisobj, coPlayer player, coSceneObject exit) { TransformF targetPosition; if (exit["reorientPlayer"].AsBool()) { targetPosition = exit.getTransform(); } else { targetPosition = exit.getTransform(); TransformF playerrot = player.getTransform(); targetPosition.MOrientation.x = playerrot.MOrientation.x; targetPosition.MOrientation.y = playerrot.MOrientation.y; targetPosition.MOrientation.z = playerrot.MOrientation.z; 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(); }
/// <summary> /// Creates Matrix from vector. /// </summary> /// <param name="transform"> </param> /// <param name="vector"> </param> /// <returns> </returns> internal TransformF MathMatrixMulVector(TransformF transform, Point3F vector) { float x = transform.MPosition.x; float y = transform.MPosition.y; float z = transform.MPosition.z; float ang = transform.MAngle; float ax = transform.MOrientation.x; float ay = transform.MOrientation.y; float az = transform.MOrientation.z; float XX = vector.x; float YY = vector.y; float ZZ = vector.z; StringBuilder ret = new StringBuilder(1024); SafeNativeMethods.mMath_MatrixMulVector(x, y, z, ang, ax, ay, az, XX, YY, ZZ, ret); TransformF r = new TransformF(ret.ToString()); return(r); }
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 virtual bool mountObject(SceneObject objB, TransformF txfm = null) { if (txfm == null) { txfm = TransformF.Identity; } return(InternalUnsafeMethods.mountObject(ObjectPtr, objB.ObjectPtr, txfm.ToStruct())); }
/// <summary> /// Create Matrix from Euler. /// </summary> /// <param name="transform"> </param> /// <returns> </returns> public TransformF MathMatrixCreateFromEuler(TransformF transform) { StringBuilder ret = new StringBuilder(1024); SafeNativeMethods.mMath_MatrixCreateFromEuler(transform.mOrientationX, transform.mOrientationY, transform.mOrientationZ, ret); return(new TransformF(ret.ToString())); }
/// <summary> /// Create Matrix from Euler. /// </summary> /// <param name="transform"> </param> /// <returns> </returns> internal TransformF MathMatrixCreateFromEuler(TransformF transform) { StringBuilder ret = new StringBuilder(1024); SafeNativeMethods.mMath_MatrixCreateFromEuler(transform.MOrientation.x, transform.MOrientation.y, transform.MOrientation.z, ret); return(new TransformF(ret.ToString())); }
public virtual void setOrbitPoint(TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, Point3F offset = null, bool locked = false) { if (offset == null) { offset = Point3F.Zero; } InternalUnsafeMethods.setOrbitPoint(ObjectPtr, orbitPoint.ToStruct(), minDistance, maxDistance, initDistance, offset.ToStruct(), locked); }
public bool setOrbitMode(string orbitObject, TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, bool ownClientObj = false, Point3F offset = null, bool lockedx = false) { if (offset == null) { offset = new Point3F(0.0f, 0.0f, 0.0f); } return(pInvokes.m_ts.fnCamera_setOrbitMode(_ID, orbitObject, orbitPoint.AsString(), minDistance, maxDistance, initDistance, ownClientObj, offset.AsString(), lockedx)); }
/// <description> /// Set the object's transform (orientation and position). /// </description> /// <param name="txfm">object transform to set</param> public void SetTransform(TransformF txfm) { txfm.Alloc(); InternalUnsafeMethods.SetTransform__Args _args = new InternalUnsafeMethods.SetTransform__Args() { txfm = txfm.internalStructPtr, }; InternalUnsafeMethods.SetTransform()(ObjectPtr, _args); txfm.Free(); }
public void setOrbitPoint(TransformF orbitPoint, float minDistance, float maxDistance, float initDistance, Point3F offset = null, bool lockedx = false) { if (offset == null) { offset = new Point3F(0.0f, 0.0f, 0.0f); } pInvokes.m_ts.fnCamera_setOrbitPoint(_ID, orbitPoint.AsString(), minDistance, maxDistance, initDistance, offset.AsString(), lockedx); }
public void ArmorOnImpact(coPlayerData datablock, coPlayer player, coShapeBase collidedObject, TransformF vec, float vecLen) { TransformF p = player.getTransform(); p = p + vec; float speedDamageScale = vecLen + datablock["speedDamageScale"].AsFloat(); ShapeBaseDamage(player, "0", p.MPosition, speedDamageScale, "Impact"); }
public bool mountObject(string objB, int slot, TransformF txfm = null) { if (txfm == null) { txfm = new TransformF("0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000"); } return(pInvokes.m_ts.fnSceneObject_mountObject(_ID, objB, slot, txfm.AsString())); }
public void spawnAI(coScriptObject aiManager) { if (!console.isObject(aiManager)) { console.error("Bad aiManager!"); return; } coAIPlayer aiPlayer = AiPlayerSpawnOnPath("Team" + aiManager["aiteam"], "MissionGroup/Paths/team" + aiManager["aiteam"] + "Path"); if (aiPlayer == null) { console.error("UNABLE TO SPAWN MONSTER!@!!!!!a"); aiManager.schedule("1000", "0", "spawnai", aiManager); return; } if (!console.isObject(aiPlayer)) { console.error("UNABLE TO SPAWN MONSTER!@!!!!!"); aiManager.schedule("1000", "0", "spawnai", aiManager); return; } // m_ts.LogError("AIManager " + aiManager + " - Creating."); aiPlayer.call("FollowPath", "MissionGroup/Paths/team" + aiManager["aiteam"] + "Path", "-1"); aiPlayer.setMoveSpeed(0.8f); aiManager["player"] = aiPlayer; aiPlayer["aiManager"] = aiManager; aiPlayer["aiteam"] = aiManager["aiteam"]; ShapeBaseShapeBaseSetInventory(aiPlayer, "Lurker", 1); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerClip", 1000); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerAmmo", 1000); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerGrenadeLauncher", 1); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerGrenadeAmmo", 10); ShapeBaseShapeBaseSetInventory(aiPlayer, "ProxMine", 5); ShapeBaseShapeBaseSetInventory(aiPlayer, "DeployableTurret", 5); aiPlayer.mountImage("LurkerWeaponImage", 0, true, ""); TransformF t = aiPlayer.getTransform(); t.MPosition.z += r.Next(0, 200); aiPlayer.setTransform(t); AddObjectTo_MobSearchGroup(aiPlayer, aiManager["aiteam"].AsInt()); m_thoughtqueue.Add(new AIInterval(DateTime.Now.AddMilliseconds(500), aiPlayer)); //AIPlayerThink(aiPlayer, aiPlayer); //aiPlayer.schedule("100", "think", aiPlayer); aiscreated++; }
public virtual bool verifyObject(GameBase gobj, SceneObject entrance, SceneObject exit) { ShapeBase obj = gobj._ID; // Bail out early if we couldn't find an exit for this teleporter. if (!exit.isObject()) { console.error(string.Format("Cound not find an exit for {0}", console.GetVarString(entrance + ".name"))); return(false); } if (!obj.isMemberOfClass("Player")) { return(false); } // If the entrance is once sided, make sure the object // approached it from it's front. if (entrance["oneSided"].AsBool()) { TransformF forwardvector = new TransformF(entrance.getForwardVector()); Point3F velocity = obj.getVelocity(); 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 (obj["isTeleporting"].AsBool()) { return(false); } // We only want to teleport players // So bail out early if we have found any // other object. if (entrance["timeOfLastTeleport"].AsInt() > 0 && entrance["teleporterCooldown"].AsInt() > 0) { int currentTime = console.getSimTime(); int timedifference = currentTime - entrance["timeOfLastTeleport"].AsInt(); SimDataBlock db = console.getDatablock(entrance); if (timedifference <= db["teleporterCooldown"].AsInt()) { return(false); } } } return(true); }
/// <summary>Check if there is the space at the given transform is free to spawn into.</summary> /// <description> /// 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. /// </description> /// <param name="txfm">Deploy transform to check</param> /// <returns>True if the space is free, false if there is already something in the way.</returns> /// <remarks> This is a server side only check, and is not actually limited to spawning. /// </remarks> public bool CheckDeployPos(TransformF txfm) { txfm.Alloc(); InternalUnsafeMethods.CheckDeployPos__Args _args = new InternalUnsafeMethods.CheckDeployPos__Args() { txfm = txfm.internalStructPtr, }; bool _engineResult = InternalUnsafeMethods.CheckDeployPos()(ObjectPtr, _args); txfm.Free(); return(_engineResult); }
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 void ArmorDamage(coPlayerData datablock, coPlayer player, TransformF position, coPlayer sourceobject, float damage, string damageType) { if (!player.isObject()) { return; } if (player.getState() == "Dead") { return; } if (damage == 0.0) { return; } player.applyDamage(damage); const string location = "Body"; //PlayerUpdateHealth(player); coGameConnection client = player["client"]; //Only continue if it is a player, if it is an AI return. if (!client.isObject()) { return; } coGameConnection sourceClient = null; if (sourceobject != 0) { sourceClient = sourceobject["client"]; } if (player.getDamageLevel() >= 99) { player.unmountImage(0); } // Determine damage direction if (damageType != "Suicide") { PlayerSetDamageDirection(player, sourceobject, position); } if (player.getState() == "Dead") { GameConnectionOnDeath(client, sourceobject, sourceClient, damageType, location); } }
public static void ServerPlay3D(SFXProfile profile, TransformF transform) { SimSet ClientGroup = Sim.FindObject <SimSet>("ClientGroup"); // 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 (uint i = 0; i < ClientGroup.getCount(); i++) { ClientGroup.getObject(i).As <GameConnectionToClient>().play3D(profile, transform); } }
public void DemoPlayerOnMoveStuck(coPlayerData datablock, coAIPlayer npc) { coSimSet path = npc["path"]; uint targetnode = datablock["targetNode"].AsUint(); coMarker node = path.getObject(targetnode); TransformF t = node.getTransform(); t.MPosition.z += r.Next(10, 100); t.MPosition.x += r.Next(10, 30); t.MPosition.y += r.Next(10, 30); npc.setTransform(t); }
public virtual void throwObject(Item obj) { // Throw the given object in the direction the shape is looking. // The force value is hardcoded according to the current default // object mass and mission gravity (20m/s^2). float throwforce = ((SimDataBlock)getDataBlock())["throwForce"].AsFloat(); if (throwforce == 0) { throwforce = 20; } // Start with the shape's eye vector... Point3F eye = getEyeVector(); Point3F vec = eye.vectorScale(throwforce); // Add a vertical component to give the object a better arc double verticalForce = throwforce / 2.0; float dot = Point3F.vectorDot(new Point3F("0 0 1"), eye); if (dot < 0) { dot = dot * -1; } vec = vec + Point3F.vectorScale(new Point3F(string.Format("0 0 {0}", verticalForce)), 1 - dot); vec = vec + getVelocity(); // Set the object's position and initial velocity TransformF pos = new TransformF(Util.getBoxCenter(getWorldBox())); obj.setTransform(pos); obj.applyImpulse(pos.GetPosition(), vec); // Since the object is thrown from the center of the shape, // the object needs to avoid colliding with it's thrower. obj.setCollisionTimeout(this); //todo Should we add this code in to destroy things after they have been thrown? if ((obj.getClassName() != "AITurretShape") && (obj.getClassName() != "ProximityMine")) { obj.schedule("2000", "delete"); } }
/// <summary>Mount objB to this object at the desired slot with optional transform.</summary> /// <description> /// /// </description> /// <param name="objB">Object to mount onto us</param> /// <param name="slot">Mount slot ID</param> /// <param name="txfm">(optional) mount offset transform</param> /// <returns>true if successful, false if failed (objB is not valid)</returns> public bool MountObject(SceneObject objB, TransformF txfm = null) { txfm = txfm ?? new TransformF("0 0 0 1 0 0 0 true"); txfm.Alloc(); InternalUnsafeMethods.MountObject__Args _args = new InternalUnsafeMethods.MountObject__Args() { objB = objB.ObjectPtr, txfm = txfm.internalStructPtr, }; bool _engineResult = InternalUnsafeMethods.MountObject()(ObjectPtr, _args); txfm.Free(); return(_engineResult); }
public virtual void pushFront(TransformF transform, float speed = 1.0f, string type = "Normal", string path = "Linear") { if (type == null) { type = "Normal"; } if (path == null) { path = "Linear"; } InternalUnsafeMethods.pushFront(ObjectPtr, transform.ToStruct(), speed, type, path); }
public override void onMoveStuck(AIPlayer obj) { SimSet path = this["path"]; uint targetnode = this["targetNode"].AsUint(); Marker node = path.getObject(targetnode); TransformF t = node.getTransform(); t.mPositionZ += r.Next(10, 100); t.mPositionX += r.Next(10, 30); t.mPositionY += r.Next(10, 30); this.setTransform(t); }
/// <summary>Adds a new knot to the back of a path camera's path.</summary> /// <description> /// /// </description> /// <param name="transform">Transform for the new knot. In the form of "x y z ax ay az aa" such as returned by SceneObject::getTransform()</param> /// <param name="speed">Speed setting for this knot.</param> /// <param name="type">Knot type (Normal, Position Only, Kink).</param> /// <param name="path">%Path type (Linear, Spline).</param> /// <code> /// // 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 back of its path /// %pathCamera.pushBack(%transform,%speed,%type,%path); /// </code> public void PushBack(TransformF transform, float speed = 1f, string type = "Normal", string path = "Linear") { transform.Alloc(); InternalUnsafeMethods.PushBack__Args _args = new InternalUnsafeMethods.PushBack__Args() { transform = transform.internalStructPtr, speed = speed, type = type, path = path, }; InternalUnsafeMethods.PushBack()(ObjectPtr, _args); transform.Free(); }
/// <summary> /// Thread-Safe /// </summary> /// <param name="aiManager"></param> public static void spawnAI(ScriptObject aiManager) { //lock (Omni.self.tick) { if (!aiManager.isObject()) { omni.console.error("Bad aiManager!"); return; } DemoPlayer aiPlayer = SpawnOnPath("Team" + aiManager["aiteam"], "MissionGroup/Paths/team" + aiManager["aiteam"] + "Path"); if (aiPlayer == null) { omni.console.error("UNABLE TO SPAWN MONSTER!@!!!!!a"); return; } if (!omni.console.isObject(aiPlayer)) { omni.console.error("UNABLE TO SPAWN MONSTER!@!!!!!"); return; } aiPlayer.FollowPath("MissionGroup/Paths/team" + aiManager["aiteam"] + "Path", 0); aiPlayer.setMoveSpeed(0.8f); aiManager["player"] = aiPlayer; aiPlayer["aiManager"] = aiManager; aiPlayer["aiteam"] = aiManager["aiteam"]; aiPlayer.setInventory("Lurker", 1); aiPlayer.setInventory("LurkerClip", 1000); aiPlayer.setInventory("LurkerAmmo", 1000); aiPlayer.setInventory("LurkerGrenadeLauncher", 1); aiPlayer.setInventory("LurkerGrenadeAmmo", 10); aiPlayer.setInventory("ProxMine", 5); aiPlayer.setInventory("DeployableTurret", 5); aiPlayer.mountImage("LurkerWeaponImage", 0, true, ""); TransformF t = aiPlayer.getTransform(); t.mPositionZ += r.Next(0, 200); aiPlayer.setTransform(t); aiPlayer.AddObjectTo_MobSearchGroup(aiManager["aiteam"].AsInt()); m_thoughtqueue.Add(new AIInterval(DateTime.Now.AddMilliseconds(500), aiPlayer)); aiscreated++; } }
public coAIPlayer AiPlayerSpawnOnPath(string ainame, coSimSet path) { if (!console.isObject(path)) { return(null); } coMarker node = path.getObject((uint)r.Next(0, path.getCount() - 1)); TransformF transform = node.getTransform(); return(AiPlayerSpawn(ainame, transform)); }
public coAIPlayer AiPlayerSpawn(string name, TransformF spawnPoint) { Torque_Class_Helper tch = new Torque_Class_Helper("AiPlayer"); tch.Props.Add("dataBlock", "DemoPlayer"); tch.Props.Add("path", ""); coAIPlayer npc = tch.Create(); ((coSimSet)"MissionCleanup").pushToBack(npc); npc.setShapeName(name); npc.setTransform(spawnPoint); return(npc); }
/// <summary> /// Spawns a AI on a passed path. /// </summary> /// <param name="ainame"></param> /// <param name="path"></param> /// <returns></returns> public static DemoPlayer SpawnOnPath(string ainame, SimSet path) { if (!omni.console.isObject(path)) { return(null); } Marker node = path.getObject((uint)r.Next(0, path.getCount() - 1)); TransformF transform = node.getTransform(); return(Spawn(ainame, transform)); }