public override void onImageMount(ShapeBase obj, int slot, float dt) { GameConnection client = obj["client"]; string ammoName = string.Empty; ammoName = this["ammo"].getName(); int currentammo = 0; int ammountinClips = 0; if (isField("clip")) { if (obj.getInventory(this["ammo"]).AsBool()) { obj.setImageAmmo(slot, true); currentammo = obj.getInventory(this["ammo"]); } else if (obj.getInventory(this["clip"]) > 0) { obj.setInventory(this["ammo"], this["ammo.maxInventory"].AsInt()); obj.setImageAmmo(slot, true); currentammo = this["ammo.maxInventory"].AsInt(); ammountinClips += obj["remaining" + ammoName].AsInt(); } else currentammo = obj["remaining" + ammoName].AsInt(); ammountinClips = obj.getInventory(this["clip"]); ammountinClips *= this["ammo.maxInventory"].AsInt(); if ((obj["client"] != string.Empty) && !obj["isAiControlled"].AsBool()) client.refreshWeaponHud(currentammo, this["item.previewImage"], this["item.reticle"], this["item.zoomReticle"], ammountinClips); } else if (this["ammo"] != string.Empty) { if (obj.getInventory(this["ammo"]).AsBool()) { obj.setImageAmmo(slot, true); currentammo = obj.getInventory(this["ammo"]); } else currentammo = 0; if (obj["client"] != string.Empty && !obj["isAiControlled"].AsBool()) client.refreshWeaponHud(1, this["item.previewImage"], this["item.reticle"], this["item.zoomReticle"], currentammo); } }
public override void onImageMount(ShapeBase obj, int slot, float dt) { obj.setImageAmmo(slot, true); int numTurrets = obj.getInventory(this["item"]); if (obj["client"] != string.Empty && obj.isAiControlled == false) ((GameConnection) obj["client"]).refreshWeaponHud(1, this["item.previewImage"], this["item.reticle"], this["item.zoomReticle"], numTurrets); }
public override void onImageMount(ShapeBase obj, int slot, float dt) { obj.setImageAmmo(slot, true); int numofmines = obj.getInventory(this["item"]); string previewImage = this["item.previewImage"]; string reticle = this["item.reticle"]; string zoomReticle = this["item.zoomReticle"]; GameConnection client = obj["client"]; client.refreshWeaponHud(1, previewImage, reticle, zoomReticle, numofmines); }
public virtual void clearAmmoClip(ShapeBase 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 (!this["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 = stashSpareAmmo(obj); if (obj.getInventory(this["clip"]) > 0 || pocketAmount != 0) obj.setImageAmmo(slot, false); }
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); } } }