public override void onAdd(GameBase obj) { ShapeBase sbobj = obj._ID; sbobj.setRechargeRate(this["rechargeRate"].AsFloat()); sbobj.setEnergyLevel(this["MaxEnergy"].AsFloat()); sbobj.setRepairRate(0); if (obj["mountable"] == "1" || obj["mountable"] == string.Empty) { this.isMountable((TurretShape)sbobj, true.AsString()); } else { this.isMountable((TurretShape)sbobj, false.AsString()); } if (this["nameTag"] != string.Empty) { sbobj.setShapeName(this["nameTag"]); } for (int i = 0; i < this["numWeaponMountPoints"].AsInt(); i++) { sbobj.incInventory(this["weapon[" + i + "]"], 1); ItemData weaponAmmo = this["weaponAmmo[" + i + "]"]; string weaponAmmoAmount = this["weaponAmmoAmount[" + i + "]"]; sbobj.incInventory(weaponAmmo, weaponAmmoAmount.AsInt()); bool startLoaded = this["startLoaded"].AsBool(); sbobj.mountImage(this["weapon[" + i + "].Image"], i, startLoaded, string.Empty); sbobj.setImageGenericTrigger(i, 0, false); } if (this["enterSequence"] != string.Empty) { obj["entranceThread"] = "0"; int et = obj["entranceThread"].AsInt(); string es = this["enterSequence"]; sbobj.playThread(et, es); sbobj.pauseThread(et); } else { obj["entranceThread"] = "-1"; } }
public override bool onPickup(Item obj, ShapeBase user, int amount) { int count = obj["count"].AsInt(); //string count = console.GetVarString(item + ".count"); if (count == 0) { count = this["count"].AsInt(); if (count == 0) { if (this["maxInventory"] != string.Empty) { if (count != this["maxInventory"].AsInt()) { return(false); } } else { count = 1; } } } user.incInventory(((this).getName()), count); GameConnection client = user["client"]; if (client.isObject()) { message.MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), this["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 (obj.isStatic()) { obj.Respawn(); } else { obj.delete(); } return(true); }
public override bool onPickup(Item obj, ShapeBase user, int amount) { int count = obj["count"].AsInt(); //string count = console.GetVarString(item + ".count"); if (count == 0) { count = this["count"].AsInt(); if (count == 0) { if (this["maxInventory"] != string.Empty) { if (count != this["maxInventory"].AsInt()) return false; } else count = 1; } } user.incInventory(((this).getName()), count); GameConnection client = user["client"]; if (client.isObject()) message.MessageClient(client, "MsgItemPickup", console.ColorEncode(@"\c0You picked up %1"), this["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 (obj.isStatic()) obj.Respawn(); else obj.delete(); return true; }
public virtual int stashSpareAmmo(ShapeBase obj) { // 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 ShapeBaseData ammo = this["ammo"]; if (obj.getInventory(ammo) < this["ammo.maxInventory"].AsInt()) { string nameOfAmmoField = "remaining" + ammo.getName(); int amountInPocket = obj[nameOfAmmoField].AsInt(); int amountIngun = obj.getInventory(this["ammo"]); int combinedammo = amountInPocket + amountIngun; if (combinedammo >= this["ammo.maxInventory"].AsInt()) { obj[nameOfAmmoField] = (combinedammo - this["ammo.maxInventory"].AsInt()).AsString(); obj.incInventory(this["clip"], 1); } else if (obj.getInventory(this["clip"]) > 0) obj[nameOfAmmoField] = combinedammo.AsString(); return obj[nameOfAmmoField].AsInt(); } return 0; }