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 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 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 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 WeaponImageReloadAmmoClip(coItemData thisobj, coShapeBase obj, int slot) { string ammoname = ((coItemData)thisobj["ammo"]).getName(); if (thisobj != obj.getMountedImage(slot)) return; if (!thisobj.isField("clip")) return; if (ShapeBaseShapeBaseGetInventory(obj, thisobj["clip"]) > 0) { ShapeBaseShapeBaseDecInventory(obj, thisobj["clip"], 1); ShapeBaseShapeBaseSetInventory(obj, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt()); obj.setImageAmmo(slot, true); } else { int amountInPocket = obj["remaining" + ((coItem)thisobj["ammo"]).getName()].AsInt(); if (amountInPocket > 0) { obj["remaining" + ((coItem)thisobj["ammo"]).getName()] = "0"; ShapeBaseShapeBaseSetInventory(obj, thisobj["ammo"], amountInPocket); obj.setImageAmmo(slot, true); } } }
public coItem ItemDataCreateItem(coItemData datablock) { Torque_Class_Helper tch = new Torque_Class_Helper("Item"); tch.Props.Add("dataBlock", datablock); tch.Props.Add("static", "true"); tch.Props.Add("rotate", "true"); return tch.Create(); }
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 int ShapeBaseShapeBaseMaxInventory(coShapeBase thisobj, coItemData data) { if (data.isField("clip")) return data["maxInventory"].AsInt(); return (( coSimDataBlock)thisobj.getDataBlock())["maxInv[" + data.getName() + "]"].AsInt(); }
public bool ShapeBaseShapeBaseThrow(coShapeBase thisobj, coItemData data, int amount = 1) { bool functionresult = false; if (ShapeBaseShapeBaseGetInventory(thisobj, data) > 0) { coSimObject objectid = data.call("onThrow", thisobj, amount.AsString()); { if (objectid != 0) { thisobj.call("throwObject", objectid); AudioServerPlay3D("ThrowSnd", thisobj.getTransform()); functionresult = true; } } } return functionresult; }
public int ShapeBaseShapeBaseGetInventory(coShapeBase thisobj, coItemData data) { return thisobj.isObject() ? thisobj["inv[" + data.getName() + "]"].AsInt() : 0; }
public int ShapeBaseShapeBaseDecInventory(coShapeBase shapebase, coItemData data, int amount = 0) { int total = shapebase["inv[" + data.getName() + "]"].AsInt(); if (total > 0) { if (total < amount) amount = total; ShapeBaseShapeBaseSetInventory(shapebase, data, (total - amount)); return amount; } return 0; }
public int ShapeBaseShapeBaseSetInventory(coShapeBase thisobj, coItemData data, int value = 0) { if (thisobj == "") return 0; int max = 0; max = ShapeBaseShapeBaseMaxInventory(thisobj, data); if (value > max) value = max; int amount = thisobj["inv[" + data.getName() + "]"].AsInt(); if (amount != value) { thisobj["inv[" + data.getName() + "]"] = value.AsString(); if (console.isMethodInNamespace(data, "onInventory")) data.call("onInventory", thisobj, value.AsString()); //string datablock = console.getDatablock(thisobj).AsString(); if (console.isObject((( coSimDataBlock)thisobj.getDataBlock())) && console.isMethodInNamespace((( coSimDataBlock)thisobj.getDataBlock()), "onInventory")) (( coSimDataBlock)thisobj.getDataBlock()).call("onInventory", data, value.AsString()); } return value; }
public int ShapeBaseShapeBaseIncInventory(coShapeBase player, coItemData datablock, int amount) { int maxamount = ShapeBaseShapeBaseMaxInventory(player, datablock); int total = player["inv[" + datablock.getName() + "]"].AsInt(); if (total < maxamount) { if (total + amount > maxamount) { amount = (maxamount - total); } ShapeBaseShapeBaseSetInventory(player, datablock, (total + amount)); return amount; } return 0; }
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 string ItemDataOnThrow(coItemData datablock, coPlayer player, int amount) { if (amount == 0) amount = 1; if (amount > datablock["maxInventory"].AsInt()) amount = datablock["maxInventory"].AsInt(); if (!amount.AsBool()) return "0"; ShapeBaseShapeBaseDecInventory(player, datablock, amount); // Construct the actual object in the world, and add it to // the mission group so it's cleaned up when the mission is // done. The object is given a random z rotation. Torque_Class_Helper tch = new Torque_Class_Helper("Item", ""); tch.Props.Add("datablock", datablock); tch.Props.Add("rotation", @"""0 0 1 " + (new Random().Next(0, 360)) + @""""); tch.Props.Add("count", amount.AsString()); coItem item = tch.Create(); ((coSimSet)"MissionGroup").pushToBack(item); ItemschedulePop(item); return item; }
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 bool ShapeBaseShapeBaseHasInventory(coShapeBase thisobj, coItemData data) { int amount = thisobj["inv[" + data.getName() + "]"].AsInt(); return amount > 0; }