public void PlayerPlayDeathAnimation(coPlayer player) { int numDeathAnimations = player.getNumDeathAnimations(); if (numDeathAnimations <= 0) { return; } coGameConnection client = player["client"]; if (client.isObject()) { int deathidx = client["deathIdx"].AsInt(); if ((deathidx > numDeathAnimations) || (deathidx == 0)) { deathidx = 1; } player.setActionThread("Death" + deathidx, false, true); deathidx++; client["deathIdx"] = deathidx.AsString(); } else { int r = new Random().Next(1, numDeathAnimations); player.setActionThread("Death" + r, false, true); } }
public void ServerCmdPlayDeath(coGameConnection client, string anim) { if (client.isObject()) { PlayerPlayDeathAnimation(client["player"]); } }
public void ServerCmdTestAnimation(coGameConnection client, string anim) { if (client.isObject()) { ((coPlayer)client["player"]).call("playTestAnimation", anim); } }
public void ServerCmdSuicide(coGameConnection client) { if (client.isObject()) { PlayerKill(client["player"], "Suicide"); } }
public void ArmorOnDisabled(coPlayerData datablock, coPlayer player, string state) { player.setImageTrigger(0, false); coItem item = (((coItemData)(player.getMountedImage(WeaponSlot)))["item"]); if (item.isObject()) { int amount = ShapeBaseShapeBaseGetInventory(player, (item["image.ammo"])); if (amount.AsBool()) { ShapeBaseShapeBaseThrow(player, (item["image.clip"]), 1); } } ShapeBaseTossPatch(player); PlayerPlayDeathCry(player); PlayerPlayDeathAnimation(player); //If it's a player check..... coGameConnection client = player["client"]; if (client.isObject()) { console.commandToClient(client, console.addTaggedString("toggleVehicleMap"), new[] { "false" }); } int ctov = iGlobal["$CorpseTimeoutValue"]; player.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true"); player.schedule(ctov.AsString(), "delete"); }
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 void ProxMineOnInventory(coProximityMine thisobj, coPlayer player, int amount) { coGameConnection client = player["client"]; if (client.isObject()) { GameConnectionSetAmmoAmountHud(client, 1, amount); } if ((amount == 0) && player.isMethod("getMountSlot")) { ShapeBaseCycleWeapon(player, "prev"); } }
public bool ItemDataOnPickUp(coItemData datablock, coItem item, coPlayer player, string amount) { int count = item["count"].AsInt(); //string count = console.GetVarString(item + ".count"); if (count == 0) { count = datablock["count"].AsInt(); if (count == 0) { if (datablock["maxInventory"] != "") { if (count != datablock["maxInventory"].AsInt()) { return(false); } } else { count = 1; } } } ShapeBaseShapeBaseIncInventory(player, (((coItemData)datablock).getName()), count); coGameConnection client = player["client"]; if (client.isObject()) { MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), datablock["pickupName"]); } // If the item is a static respawn item, then go ahead and // respawn it, otherwise remove it from the world. // Anything not taken up by inventory is lost. if (item.isStatic()) { item.call("respawn"); } else { item.delete(); } return(true); }
public void GameConnectiononDataBlocksDone(coGameConnection thisobj, string missionSequence) { // Make sure to ignore calls from a previous mission load if (missionSequence != sGlobal["$missionSequence"]) { return; } if (thisobj["currentPhase"].AsInt() != 1) { return; } thisobj["currentPhase"] = "1.5"; // On to the next phase if (thisobj.isObject()) { console.commandToClient(thisobj, "MissionStartPhase2", new[] { sGlobal["$missionSequence"], sGlobal["$Server::MissionFile"] }); } }
public void ArmorOnCollision(coPlayerData datablock, coPlayer player, coShapeBase col) { if (player.getState() == "Dead") { return; } // Try and pickup all items if (col.getClassName() == "Item") { player.call("pickup", col); return; } //AI are not allowed to drive they are lousey drivers.... coGameConnection client = player["client"]; if (!client.isObject()) { return; } //Mount Vehicle. if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) { return; } coVehicleData db = col.getDataBlock(); if (((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool())) { return; } // Only mount drivers for now. ((coGameConnection)player["client"]).setFirstPerson(false); // For this specific example, only one person can fit // into a vehicle int mount = col.getMountNodeObject(0); if (mount > 0) { return; } // For this specific FPS Example, always mount the player to node 0 col.mountObject(player, 0, new TransformF(true)); player["mVehicle"] = col; }
public void GameConnectionLoadMission(coGameConnection client) { // Send over the information that will display the server info // when we learn it got there, we'll send the data blocks client["currentPhase"] = "0"; if (client.isAIControlled()) { GameConnectionOnClientEnterGame(client); } else { if (client.isObject()) { console.commandToClient(client, "MissionStartPhase1", new[] { sGlobal["$missionSequence"], sGlobal["$Server::MissionFile"], sGlobal["MissionGroup.musicTrack"] }); } console.print("*** Sending mission load to client: " + sGlobal["$Server::MissionFile"]); } }
public void ArmorOnUnmount(coPlayerData datablock, coPlayer player, coVehicle vehicle, int node) { if (node != 0) { return; } player.mountImage(player["lastWeapon"], WeaponSlot, true, ""); player.setControlObject(""); if (!player["lastperson"].AsBool()) { return; } coGameConnection client = player["client"]; if (client.isObject()) { client.setFirstPerson(player["lastperson"].AsBool()); } }
public bool ShapeBaseShapeBaseUse(coShapeBase thisobj, coItemData data) { coGameConnection client = thisobj.getControllingClient(); if (client.isObject()) { double defaultfov = client.getControlCameraDefaultFov(); double fov = client.getControlCameraFov(); if (defaultfov != fov) { return(false); } } if (ShapeBaseShapeBaseGetInventory(thisobj, data) > 0) { return(data.call("onUse", thisobj).AsBool()); } return(false); }
public void ArmorOnMount(coPlayerData datablock, coPlayer player, coVehicle vehicle, int node) { coVehicleData vehicleDataBlock = vehicle.getDataBlock(); if (node == 0) { player.setTransform(new TransformF("0 0 0 0 0 1 0")); string mountPose = vehicleDataBlock["mountPose[" + node + "]"]; player.setActionThread(mountPose, true, true); player["lastWeapon"] = player.getMountedImage(WeaponSlot).AsString(); coGameConnection client = player["client"]; if (client.isObject()) { player["lastperson"] = client.isFirstPerson().AsString(); } player.unmountImage(WeaponSlot); player.setControlObject(vehicle); if (player.getClassName() == "Player") { console.commandToClient(player["client"], console.addTaggedString("toggleVehicleMap"), new[] { "true" }); } } else { string pose = vehicleDataBlock["mountPose[" + node + "]"]; player.setActionThread(pose != "" ? pose : "root", false, true); } }
public void GameConnectionOnDeath(coGameConnection client, coPlayer sourceobject, coGameConnection sourceclient, string damagetype, string damloc) { if (client.isObject()) { if (client["ownedTurrets"] == "") { client["ownedTurrets"] = new Torque_Class_Helper("SimSet").Create().AsString(); } coSimSet simSet = client["ownedTurrets"]; for (uint i = 0; i < simSet.getCount(); i++) { ((coSimObject)simSet.getObject(i)).schedule("10", "delete"); } } // clear the weaponHUD GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0); coPlayer player = client["player"]; // Clear out the name on the corpse player.setShapeName(""); // Update the numerical Health HUD //PlayerUpdateHealth(player); // Switch the client over to the death cam and unhook the player object. coCamera camera = client["camera"]; if (camera.isObject() && player.isObject()) { camera.call("setMode", "Corpse", player, "", ""); client.setControlObject(camera); } else { console.print("------------>Failed to Switch the client over to the death cam."); } client["player"] = "0"; // Display damage appropriate kill message string sendMsgFunction = "sendMsgClientKilled_" + damagetype; if (!console.isFunction(sendMsgFunction)) { sendMsgFunction = "sendMsgClientKilled_Default"; } console.Call(sendMsgFunction, new string[] { "MsgClientKilled", client, sourceclient, damloc }); // Dole out points and check for win if ((damagetype == "Suicide") || (sourceclient == client)) { IncDeaths(client, "1", "1"); IncScore(client, "-1", "0"); } else { IncDeaths(client, "1", "0"); IncScore(sourceclient, "1", "1"); IncKills(sourceclient, "1", "0"); } }
public string AiTurretShapeDataOnThrow(coAITurretShapeData thisobj, coPlayer user, int amount) { if (amount == 0) { amount = 1; } if (thisobj["maxInventory"] != "") { if (amount > thisobj["maxInventory"].AsInt()) { amount = thisobj["maxInventory"].AsInt(); } } if (amount == 0) { return("0"); } ShapeBaseShapeBaseDecInventory(user, thisobj, amount); //console.Call(user, "decInventory", new[] {thisobj, amount}); TransformF rot = new TransformF(user.getEulerRotation()); Torque_Class_Helper tc_obj = new Torque_Class_Helper("AITurretShape", ""); tc_obj.Props.Add("datablock", thisobj); tc_obj.Props.Add("rotation", string.Format("{0}0 0 1 {1}{0}", '"', rot.MPosition.z)); tc_obj.Props.Add("count", "1"); tc_obj.Props.Add("sourceObject", user); tc_obj.Props.Add("client", console.GetVarString(string.Format("{0}.client", user))); tc_obj.Props.Add("isAiControlled", "1"); coAITurretShape obj = tc_obj.Create(); ((coSimSet)"MissionGroup").pushToBack(obj); obj.call("addToIgnoreList", user); coGameConnection client = user["client"]; if (client.isObject()) { if (client["ownedTurrets"] == "") { client["ownedTurrets"] = new Torque_Class_Helper("SimSet", "").Create().AsString(); } coSimSet SimSet_id = client["ownedTurrets"]; int countofitems = SimSet_id.getCount(); for (uint i = 0; i < countofitems; i++) { coAITurretShape turret = SimSet_id.getObject(i); turret.call("addToIgnoreList", obj); obj.call("addToIgnoreList", turret); } SimSet_id.pushToBack(obj); } return(obj); }
public void PlayerSetDamageDirection(coPlayer player, coPlayer sourceObject, TransformF damagePos) { if (sourceObject.isObject()) { damagePos = console.isField(sourceObject, "initialPosition") ? new TransformF(sourceObject["initialPosition"]) : sourceObject.getTransform(); } TransformF dp = damagePos; Point3F wbc = player.getWorldBoxCenter(); TransformF damagevec = dp - new TransformF(wbc); damagevec = damagevec.normalizeSafe(); coGameConnection client = player["client"]; if (!client.isObject()) { return; } coCamera cameraobject = client.getCameraObject(); TransformF inverseTransform = cameraobject.getInverseTransform(); damagevec = math.MatrixMulVector(inverseTransform, damagevec.MPosition); float[] components = new float[6]; string[] directions = new string[6]; directions[0] = "Left"; directions[1] = "Right"; directions[2] = "Bottom"; directions[3] = "Front"; directions[4] = "Bottom"; directions[5] = "Top"; components[0] = -damagevec.MPosition.x; components[1] = damagevec.MPosition.x; components[2] = -damagevec.MPosition.y; components[3] = damagevec.MPosition.y; components[4] = -damagevec.MPosition.z; components[5] = damagevec.MPosition.z; string damagedirection = string.Empty; float max = 0; for (int i = 0; i < 6; i++) { if (components[i] <= max) { continue; } damagedirection = directions[i]; max = components[i]; } if (console.isObject(client)) { console.commandToClient(client, console.addTaggedString("setDamageDirection"), new[] { damagedirection }); } }