public string ProximityMineDataOnThrow(coItemData datablock, coPlayer player, int amount) { ShapeBaseShapeBaseDecInventory(player, datablock, 1); Torque_Class_Helper tch = new Torque_Class_Helper("ProximityMine", ""); tch.Props.Add("datablock", datablock); tch.Props.Add("sourceObject", player); tch.Props.Add("rotation", string.Format("\"0 0 1 {0} \"", new Random().NextDouble()*360)); tch.Props.Add("static", "false"); tch.Props.Add("client", player["client"]); coProximityMine pm = (tch.Create()); ((coSimSet) "MissionCleanup").pushToBack(pm); return pm; }
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; }
public void WeaponOnUser(coScriptObject data, coPlayer obj) { if (obj.getMountedImage(WeaponSlot) == data["image"].AsInt()) return; AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(data["image"], WeaponSlot, true, ""); if (obj["client"].AsBool()) { if (data["description"] != "") MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", data["description"]); else MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } if (obj.isInNamespaceHierarchy("Player")) return; obj.allowAllPoses(); coSimObject image = data["image"]; if (image["jumpingDisallowed"].AsBool()) obj.allowJumping(false); if (image["jetJumpingDisallowed"].AsBool()) obj.allowJetJumping(false); if (image["sprintDisallowed"].AsBool()) obj.allowSprinting(false); if (image["crouchDisallowed"].AsBool()) obj.allowCrouching(false); if (image["proneDisallowed"].AsBool()) obj.allowProne(false); if (image["swimmingDisallowed"].AsBool()) obj.allowSwimming(false); }
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 WeaponImageOnMount(coScriptObject thisobj, coPlayer player, int slot) { coGameConnection client = player["client"]; string ammoName = ""; ammoName = ((coItemData)thisobj["ammo"]).getName(); int currentammo = 0; int ammountinClips = 0; if (thisobj.isField("clip")) { if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool()) { player.setImageAmmo(slot, true); currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]); } else if (ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]) > 0) { ShapeBaseShapeBaseSetInventory(player, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt()); player.setImageAmmo(slot, true); currentammo = thisobj["ammo.maxInventory"].AsInt(); ammountinClips += player["remaining" + ammoName].AsInt(); } else { ammountinClips += player["remaining" + ammoName].AsInt(); } ammountinClips = ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]); ammountinClips *= thisobj["ammo.maxInventory"].AsInt(); if ((player["client"] != "") && !player["isAiControlled"].AsBool()) { GameConnectionRefreshWeaponHud(client, currentammo, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], ammountinClips); } } else if (thisobj["ammo"] != "") { if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool()) { player.setImageAmmo(slot, true); currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]); } else currentammo = 0; if (player["client"] != "" && !player["isAiControlled"].AsBool()) GameConnectionRefreshWeaponHud(client, 1, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], currentammo); } }
public void ProxMineImageOnFire(coProximityMineData image, coPlayer player, int slot) { ShapeBaseShapeBaseThrow(player, image["item"]); }
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 void GameConnectionLoadOut(coGameConnection client, coPlayer player) { ShapeBaseClearWeaponCycle(player); ShapeBaseShapeBaseSetInventory(player, "Ryder", 1); ShapeBaseShapeBaseSetInventory(player, "RyderClip", ShapeBaseShapeBaseMaxInventory(player, "RyderClip")); ShapeBaseShapeBaseSetInventory(player, "RyderAmmo", ShapeBaseShapeBaseMaxInventory(player, "RyderAmmo")); ShapeBaseAddToWeaponCycle(player, "Ryder"); ShapeBaseShapeBaseSetInventory(player, "Lurker", 1); ShapeBaseShapeBaseSetInventory(player, "LurkerClip", ShapeBaseShapeBaseMaxInventory(player, "LurkerClip")); ShapeBaseShapeBaseSetInventory(player, "LurkerAmmo", ShapeBaseShapeBaseMaxInventory(player, "LurkerAmmo")); ShapeBaseAddToWeaponCycle(player, "Lurker"); ShapeBaseShapeBaseSetInventory(player, "LurkerGrenadeLauncher", 1); ShapeBaseShapeBaseSetInventory(player, "LurkerGrenadeAmmo", ShapeBaseShapeBaseMaxInventory(player, "LurkerGrenadeAmmo")); ShapeBaseAddToWeaponCycle(player, "LurkerGrenadeLauncher"); ShapeBaseShapeBaseSetInventory(player, "ProxMine", ShapeBaseShapeBaseMaxInventory(player, "ProxMine")); ShapeBaseAddToWeaponCycle(player, "ProxMine"); ShapeBaseShapeBaseSetInventory(player, "DeployableTurret", ShapeBaseShapeBaseMaxInventory(player, "DeployableTurret")); ShapeBaseAddToWeaponCycle(player, "DeployableTurret"); coSimDataBlock playerdatablock = player.getDataBlock(); string junk = playerdatablock["mainWeapon.image"]; if (junk == "") player.mountImage("LurkerWeaponImage", 0, true, ""); else player.mountImage(junk, 0, true, ""); //ShapeBase.mountImage(player, junk == "" ? junk : "LurkerWeaponImage", 0, true, ""); }
public void ProxMineImageOnUnmount(coProximityMineData thisobj, coPlayer player, int slot) { GameConnectionRefreshWeaponHud(player["client"], 0, "", "", "", 0); }
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); }
public void ShapeBaseAddToWeaponCycle(coPlayer player, string weapon) { player["cycleWeapon[" + player["totalCycledWeapons"].AsString() + "]"] = weapon; player["totalCycledWeapons"] = (player["totalCycledWeapons"].AsInt() + 1).AsString(); }
public void WeaponImageOnClipEmpty(coScriptObject thisobj, coPlayer obj, int slot) { thisobj.schedule("0", "reloadAmmoClip", obj, slot.AsString()); }
public int WeaponImageStashSpareAmmo(coItemData thisobj, coPlayer player) { // If the amount in our pocket plus what we are about to add from the clip // Is over a clip, add a clip to inventory and keep the remainder // on the player coItemData ammo = thisobj["ammo"]; if (ShapeBaseShapeBaseGetInventory(player, ammo) < thisobj["ammo.maxInventory"].AsInt()) { string nameOfAmmoField = "remaining" + ammo.getName(); int amountInPocket = player[nameOfAmmoField].AsInt(); int amountIngun = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]); int combinedammo = amountInPocket + amountIngun; if (combinedammo >= thisobj["ammo.maxInventory"].AsInt()) { player[nameOfAmmoField] = (combinedammo - thisobj["ammo.maxInventory"].AsInt()).AsString(); ShapeBaseShapeBaseIncInventory(player, thisobj["clip"], 1); } else if (ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]) > 0) player[nameOfAmmoField] = combinedammo.AsString(); return player[nameOfAmmoField].AsInt(); } return 0; }
public int VehicleDataFindEmptySeat(coVehicleData thisobj, coVehicle vehicle, coPlayer player) { for (int i = 0; i < thisobj["numMountPoints"].AsInt(); i++) { int node = vehicle.getMountNodeObject(i); if (node != 0) return i; } return -1; }
public int VehicleDataSwitchSeats(coVehicleData thisobj, coVehicle vehicle, coPlayer player) { for (int i = 0; i < thisobj["numMountPoints"].AsInt(); i++) { int node = vehicle.getMountNodeObject(i); if (node == player || node > 0) continue; if (node == 0) return i; } return -1; }
public void VehicleDataSetMountVehicle(coVehicleData thisobj, coVehicle vehicle, coPlayer player) { if (!vehicle.isObject() || vehicle.getDamageState() == "Destroyed") return; int node = VehicleDataFindEmptySeat(thisobj, vehicle, player); if (node == -1) return; vehicle.mountObject(player, node, new TransformF(true)); player["mVehicle"] = vehicle; }
public void VehicleDataMountPlayer(coVehicleData thisobj, coVehicle vehicle, coPlayer player) { if (!vehicle.isObject() || vehicle.getDamageState() == "Destroyed") return; player.startFade(1000, 0, true); thisobj.schedule("1000", "setMountVehicle", vehicle, player); player.schedule("1500", "startFade", "1000", "0", "false"); }
public TransformF PointInSpawnSphere(coPlayer objectToSpawn, coSpawnSphere spawnSphere) { bool spawnLocationFound = false; int attemptsToSpawn = 0; TransformF spherLocationP3F = new TransformF(); while (!spawnLocationFound && attemptsToSpawn < 5) { spherLocationP3F = spawnSphere.getTransform(); Random r = new Random(); float angleY = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F); float angleXZ = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F); int radius = spawnSphere["radius"].AsInt(); spherLocationP3F.MPosition.x += (float)(Math.Cos(angleY) * Math.Sin(angleXZ) * (r.Next(radius * -1, radius))); spherLocationP3F.MPosition.y += (float)(Math.Cos(angleXZ) * (r.Next(radius * -1, radius))); spawnLocationFound = true; // Now have to check that another object doesn't already exist at this spot. // Use the bounding box of the object to check if where we are about to spawn in is // clear. TransformF boundingboxsize = new TransformF(((coSimDataBlock)objectToSpawn.getDataBlock())["boundingBox"]); float searchRadius = boundingboxsize.MPosition.x; float boxSizeY = boundingboxsize.MPosition.y; if (boxSizeY > searchRadius) { searchRadius = boxSizeY; } List<UInt32> objectsfound = console.ContainerRadiusSearch(spherLocationP3F.MPosition, searchRadius, (UInt32)SceneObjectTypesAsUint.PlayerObjectType, false); if (objectsfound.Count > 0) spawnLocationFound = false; attemptsToSpawn++; } if (!spawnLocationFound) { spherLocationP3F = spawnSphere.getTransform(); console.warn("WARNING: Could not spawn player after 5 times"); } return spherLocationP3F; }
public void WeaponImageOnUnmount(coScriptObject thisobj, coPlayer player, int slot) { coGameConnection client = player["client"]; if (client != "" && player["isAiControlled"].AsBool()) GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0); }
public void AmmoOnInventory(coItemData thisobj, coPlayer player, int amount) { coGameConnection client = player["client"]; for (int i = 0; i < 8; i++) { coItemData image = player.getMountedImage(i); if (image <= 0) continue; if (!image["ammo"].isObject()) continue; if (console.Call(image["ammo"], "getID") != console.Call(thisobj, "getID")) continue; player.setImageAmmo(i, amount != 0); int currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj); if (player.getClassName() != "Player") continue; int amountInClips; if (thisobj["clip"].isObject()) { amountInClips = ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]); amountInClips *= thisobj["maxInventory"].AsInt(); amountInClips += player["remaining" + thisobj.getName()].AsInt(); } else { amountInClips = currentammo; currentammo = 1; } if (player["client"] != "" && !player["isAiControlled"].AsBool()) { GameConnectionSetAmmoAmountHud(client, currentammo, amountInClips); } } }
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 DetonadeOnDestroyed(coSimDataBlock thisobj, coPlayer obj, string laststate) { RadiusDamage(obj, obj.getTransform().MPosition, 10, 25, "DetonadeDamage", 2000); }
public void WeaponImageClearAmmoClip(coItemData thisobj, coPlayer obj, int slot) { //echo("WeaponImage::clearAmmoClip: " SPC %this SPC %obj SPC %slot); // if we're not empty put the remaining bullets from the current clip // in to the player's "pocket". if (!thisobj["clip"].isObject()) return; // Commenting out this line will use a "hard clip" system, where // A player will lose any ammo currently in the gun when reloading. int pocketAmount = WeaponImageStashSpareAmmo(thisobj, obj); if (ShapeBaseShapeBaseGetInventory(obj, thisobj["clip"]) > 0 || pocketAmount != 0) obj.setImageAmmo(slot, false); }
public void ProxMineOnUser(coProximityMine thisobj, coPlayer obj) { // Act like a weapon on use console.Call_Classname("Weapon", "onUse", new String[] {thisobj, obj}); }
public void AmmoClipOnPickup(coItem thisobj, string obj, coPlayer shape, string amount, int nameSpaceDepth) { int nsd = nameSpaceDepth + 1; if (!console.ParentExecute(thisobj, "onPickup", nsd, new string[] { thisobj, obj, shape, amount }).AsBool()) return; AudioServerPlay3D("WeaponPickupSound", shape.getTransform()); coItemData image = shape.getMountedImage(WeaponSlot); if (image == 0) return; if (!console.isField(image, "clip") || console.Call(string.Format("{0}.clip", image), "getID") != console.Call(thisobj, "getID")) return; bool outOfAmmo = !shape.getImageAmmo(WeaponSlot); int amountInClips = 0; int currentAmmo = ShapeBaseShapeBaseGetInventory(shape, image["ammo"]); if (console.isObject(image["clip"])) amountInClips = ShapeBaseShapeBaseGetInventory(shape, image["clip"]); int t = console.GetVarInt(string.Format("{0}.ammo.maxInventory", image)); amountInClips *= t; int amountloadedingun = console.GetVarInt(string.Format("{0}.remaining{1}", obj, console.GetVarString(string.Format("{0}.ammo", this)))); amountInClips += amountloadedingun; GameConnectionSetAmmoAmountHud(shape["client"], currentAmmo, amountInClips); if (outOfAmmo) console.Call(image, "onClipEmpty", new string[] { shape, WeaponSlot.AsString() }); }
public void ProxMineOnPickup(coProximityMine thisobj, coPlayer obj, string shape, string amount) { // Act like a weapon on pickup console.Call_Classname("Weapon", "onPickup", new string[] {thisobj, obj, shape, amount}); }
public void ShapeBaseClearWeaponCycle(coPlayer thisobj) { thisobj["totalCycledWeapons"] = "0"; }
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 void ProxMineImageOnMount(coProximityMineData thisobj, coPlayer player, int slot) { player.setImageAmmo(slot, true); int numofmines = ShapeBaseShapeBaseGetInventory(player, (thisobj["item"])); string previewImage = thisobj["item.previewImage"]; string reticle = thisobj["item.reticle"]; string zoomReticle = thisobj["item.zoomReticle"]; GameConnectionRefreshWeaponHud(player["client"], 1, previewImage, reticle, zoomReticle, numofmines); }
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; }