public void AmmoOnPickup(string thisobj, string obj, coSceneObject shape, string amount, int nameSpaceDepth) { int nsd = nameSpaceDepth + 1; if (console.ParentExecute(thisobj, "onPickup", nsd, new string[] { thisobj, obj, shape, amount }).AsBool()) { AudioServerPlay3D("AmmoPickupSound", shape.getTransform()); } }
public void DoManualDetonation(coSceneObject obj) { Torque_Class_Helper tch = new Torque_Class_Helper("Item", ""); tch.Props.Add("dataBlock", "Detonade"); coSceneObject nade = tch.Create(); ((coSimSet)"MissionCleanUp").pushToBack(nade); nade.setTransform(obj.getTransform()); nade["sourceObject"] = obj["SourceObject"]; nade.schedule("50", "setDamageState", "Destroyed"); obj.delete(); }
public void ObserverObserverSetMode(coCamera camera, string mode, coSceneObject arg1, string arg2, string arg3) { switch (mode) { case "Observer": camera.setFlyMode(); break; case "Corpse": camera.setOrbitMode(arg1, arg1.getTransform(), (float)0.5, (float)4.5, (float)4.5, false, new Point3F(), false); camera["orbitObj"] = arg1; break; } camera["mode"] = mode; }
public void HealthPatchOnCollision(coItemData healthkit_datablock, coSceneObject healthkit_instance, coPlayer player) { if (player.getDamageLevel() <= 0.00 || player.getState() == "Dead") { return; } player.applyRepair(healthkit_datablock["repairAmount"].AsFloat()); healthkit_instance.call("schedulePop"); //coGameConnection client = player["client"]; //if (!client.isObject()) // return; //using (BackgroundWorker bwr = new BackgroundWorker()) // { // bwr.DoWork += bwr_UpdateHealth; // bwr.RunWorkerAsync(new HealthKitHelper(player, healthkit_instance)); // } AudioServerPlay3D("HealthUseSound", player.getTransform()); }
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(); }
public bool TeleporterTriggerVerifyObject(coSimDataBlock thisobj, coShapeBase obj, coSceneObject entrance, coSceneObject exit) { // 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(); coSimDataBlock db = console.getDatablock(entrance); if (timedifference <= db["teleporterCooldown"].AsInt()) { return(false); } } } return(true); }
public void TeleporterTriggerOnEnterTrigger(coSimDataBlock thisobj, coSceneObject entrance, coPlayer obj) { //if (!console.isMemberOfClass(obj, "Player")) // return; if (obj["isTeleporting"].AsBool()) { return; } // Get the location of our target position coTrigger exit = entrance["exit"]; bool valid = TeleporterTriggerVerifyObject(thisobj, obj, entrance, exit); if (!valid) { return; } TeleporterTriggerTeleFrag(thisobj, obj, exit); // Create our entrance effects on all clients. coSimObject entranceeffect = entrance["entranceEffect"]; if (entranceeffect.isObject()) { foreach (coGameConnection client in ClientGroup) { if (console.isObject(client)) { console.commandToClient(client, "PlayTeleportEffect", new[] { entrance["position"], entranceeffect.getId().AsString() }); } } } TeleporterTriggerTeleportPlayer(thisobj, obj, exit); // Create our exit effects on all clients. coSimObject exitEffect = entrance["exitEffect"]; if (exitEffect.isObject()) { foreach (coGameConnection client in ClientGroup) { if (console.isObject(client)) { console.commandToClient(client, "PlayTeleportEffect", new[] { entrance["position"], exitEffect.getId().AsString() }); } } } // Record what time we last teleported so we can determine if enough // time has elapsed to teleport again int tolt = console.getSimTime(); entrance["timeOfLastTeleport"] = tolt.AsString(); // If this is a bidirectional teleporter, log it's exit too. if (exit["exit"] == entrance["name"]) { exit["timeOfLastTeleport"] = tolt.AsString(); } // Tell the client to play the 2D sound for the player that teleported. if (((coSimObject)thisobj["teleportSound"]).isObject() && ((coGameConnection)obj["client"]).isObject()) { ((coGameConnection)obj["client"]).play2D(thisobj["teleportSound"]); //GameConnection.play2D(obj, thisobj["teleportSound"]); } }
public void EnableManualDetonation(coSceneObject thisobj) { thisobj["detonadeEnabled"] = true.AsString(); }