/*note In torquescript they used a classname call to the weapon class to perform * the onPickUp and onUse. Unfortunately, we don't have that ability in CSharp. */ public override bool onPickup(Item obj, ShapeBase user, int amount) { if (!base.onPickup(obj, user, amount)) return false; Audio.AudioServerPlay3D("WeaponPickupSound", user.getTransform()); //todo do really like this, I guess they didn't want aiPlayer picking shit up. if (user.getClassName() == "Player" && user.getMountedImage(Constants.WeaponSlot) == 0) return user.Use(this); return false; }
/*note In torquescript they used a classname call to the weapon class to perform * the onPickUp and onUse. Unfortunately, we don't have that ability in CSharp. */ public override bool onPickup(Item obj, ShapeBase user, int amount) { if (!base.onPickup(obj, user, amount)) { return(false); } Audio.AudioServerPlay3D("WeaponPickupSound", user.getTransform()); //todo do really like this, I guess they didn't want aiPlayer picking shit up. if (user.getClassName() == "Player" && user.getMountedImage(Constants.WeaponSlot) == 0) { return(user.Use(this)); } return(false); }
public override bool onUse(ShapeBase obj) { if (obj.getMountedImage(Constants.WeaponSlot) == this["image"].AsInt()) return false; Audio.AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(this["image"], Constants.WeaponSlot, true, string.Empty); if (obj["client"].AsBool()) { if (this["description"] != string.Empty) message.MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", this["description"]); else message.MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } if (obj.isInNamespaceHierarchy("Player")) return false; Player player = obj._ID; player.allowAllPoses(); SimObject image = this["image"]; if (image["jumpingDisallowed"].AsBool()) player.allowJumping(false); if (image["jetJumpingDisallowed"].AsBool()) player.allowJetJumping(false); if (image["sprintDisallowed"].AsBool()) player.allowSprinting(false); if (image["crouchDisallowed"].AsBool()) player.allowCrouching(false); if (image["proneDisallowed"].AsBool()) player.allowProne(false); if (image["swimmingDisallowed"].AsBool()) player.allowSwimming(false); return true; }
public override bool onPickup(Item obj, ShapeBase user, int amount) { if (!base.onPickup(obj, user, amount)) return false; Audio.AudioServerPlay3D("WeaponPickupSound", user.getTransform()); ShapeBaseImageData image = user.getMountedImage(Constants.WeaponSlot); if (image == 0) return false; if (!console.isField(image, "clip") || image["clip"].getID() != getId()) return false; bool outOfAmmo = !user.getImageAmmo(Constants.WeaponSlot); int amountInClips = 0; int currentAmmo = user.getInventory(image["ammo"]); if (console.isObject(image["clip"])) amountInClips = user.getInventory(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; GameConnection client = user["client"]; client.setAmmoAmountHud(currentAmmo, amountInClips); if (outOfAmmo) ((WeaponImage) image.ID).onClipEmpty(user, Constants.WeaponSlot); return true; }
public override bool onUse(ShapeBase obj) { if (obj.getMountedImage(Constants.WeaponSlot) == this["image"].AsInt()) { return(false); } Audio.AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(this["image"], Constants.WeaponSlot, true, string.Empty); if (obj["client"].AsBool()) { if (this["description"] != string.Empty) { message.MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", this["description"]); } else { message.MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } } if (obj.isInNamespaceHierarchy("Player")) { return(false); } Player player = obj._ID; player.allowAllPoses(); SimObject image = this["image"]; if (image["jumpingDisallowed"].AsBool()) { player.allowJumping(false); } if (image["jetJumpingDisallowed"].AsBool()) { player.allowJetJumping(false); } if (image["sprintDisallowed"].AsBool()) { player.allowSprinting(false); } if (image["crouchDisallowed"].AsBool()) { player.allowCrouching(false); } if (image["proneDisallowed"].AsBool()) { player.allowProne(false); } if (image["swimmingDisallowed"].AsBool()) { player.allowSwimming(false); } return(true); }
public virtual void reloadAmmoClip(ShapeBase obj, int slot) { if (this != obj.getMountedImage(slot)) return; if (!this.isField("clip")) return; if (obj.getInventory(this["clip"]) > 0) { obj.decInventory(this["clip"], 1); obj.setInventory(this["ammo"], this["ammo.maxInventory"].AsInt()); obj.setImageAmmo(slot, true); } else { int amountInPocket = obj["remaining" + ((Item) this["ammo"]).getName()].AsInt(); if (amountInPocket > 0) { obj["remaining" + ((Item) this["ammo"]).getName()] = "0"; obj.setInventory(this["ammo"], amountInPocket); obj.setImageAmmo(slot, true); } } }