public override int onThrow(ShapeBase user, int amount) { if (amount == 0) amount = 1; if (this["maxInventory"] != string.Empty) { if (amount > this["maxInventory"].AsInt()) amount = this["maxInventory"].AsInt(); } if (!amount.AsBool()) return 0; user.decInventory(this, amount); //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. ObjectCreator tch = new ObjectCreator("Item", string.Empty); tch["datablock"] = this; tch["rotation"] = "0 0 1 " + (new Random().Next(0, 360)); tch["count"] = amount; Item item = tch.Create(); ((SimSet) "MissionGroup").pushToBack(item); item.SchedulePop(); return item; }
public override int onThrow(ShapeBase player, int amount) { if (amount == 0) amount = 1; if (this["maxInventory"] != string.Empty) { if (amount > this["maxInventory"].AsInt()) amount = this["maxInventory"].AsInt(); } if (amount == 0) return 0; player.decInventory(this, amount); TransformF rot = new TransformF(player.getEulerRotation()); ObjectCreator tc_obj = new ObjectCreator("AITurretShape", string.Empty); tc_obj["datablock"] = this.getName(); tc_obj["rotation"] = "0 0 1 " + rot.mPositionZ; tc_obj["count"] = "1"; tc_obj["sourceObject"] = player; tc_obj["client"] = player["client"]; tc_obj["isAiControlled"] = true; AITurretShape obj = tc_obj.Create(); ((SimSet) "MissionGroup").pushToBack(obj); //todo change to csharp obj.addToIgnoreList(player); GameConnection client = player["client"]; if (client.isObject()) { if (client["ownedTurrets"] == string.Empty) client["ownedTurrets"] = new ObjectCreator("SimSet", string.Empty).Create().AsString(); SimSet SimSet_id = client["ownedTurrets"]; int countofitems = SimSet_id.getCount(); for (uint i = 0; i < countofitems; i++) { AITurretShape turret = SimSet_id.getObject(i); turret.addToIgnoreList(obj); obj.addToIgnoreList(turret); } SimSet_id.pushToBack(obj); } return obj; }
public override int onThrow(ShapeBase player, int amount) { player.decInventory(this, 1); ObjectCreator tch = new ObjectCreator("ProximityMine", string.Empty); tch["datablock"] = getName(); tch["sourceObject"] = player; tch["rotation"] = new AngAxisF(0, 0, 1, (float)(new Random().NextDouble() * 360)); tch["static"] = false; tch["client"] = player["client"]; ProximityMine pm = (tch.Create()); ((SimSet)"MissionCleanup").pushToBack(pm); return(pm); }
public override int onThrow(ShapeBase user, int amount) { if (amount == 0) { amount = 1; } if (this["maxInventory"] != string.Empty) { if (amount > this["maxInventory"].AsInt()) { amount = this["maxInventory"].AsInt(); } } if (!amount.AsBool()) { return(0); } user.decInventory(this, amount); //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. ObjectCreator tch = new ObjectCreator("Item", string.Empty); tch["datablock"] = this; tch["rotation"] = "0 0 1 " + (new Random().Next(0, 360)); tch["count"] = amount; Item item = tch.Create(); ((SimSet)"MissionGroup").pushToBack(item); item.SchedulePop(); return(item); }
public override int onThrow(ShapeBase player, int amount) { if (amount == 0) { amount = 1; } if (this["maxInventory"] != string.Empty) { if (amount > this["maxInventory"].AsInt()) { amount = this["maxInventory"].AsInt(); } } if (amount == 0) { return(0); } player.decInventory(this, amount); TransformF rot = new TransformF(player.getEulerRotation()); ObjectCreator tc_obj = new ObjectCreator("AITurretShape", string.Empty); tc_obj["datablock"] = this.getName(); tc_obj["rotation"] = "0 0 1 " + rot.mPositionZ; tc_obj["count"] = "1"; tc_obj["sourceObject"] = player; tc_obj["client"] = player["client"]; tc_obj["isAiControlled"] = true; AITurretShape obj = tc_obj.Create(); ((SimSet)"MissionGroup").pushToBack(obj); //todo change to csharp obj.addToIgnoreList(player); GameConnection client = player["client"]; if (client.isObject()) { if (client["ownedTurrets"] == string.Empty) { client["ownedTurrets"] = new ObjectCreator("SimSet", string.Empty).Create().AsString(); } SimSet SimSet_id = client["ownedTurrets"]; int countofitems = SimSet_id.getCount(); for (uint i = 0; i < countofitems; i++) { AITurretShape turret = SimSet_id.getObject(i); turret.addToIgnoreList(obj); obj.addToIgnoreList(turret); } SimSet_id.pushToBack(obj); } return(obj); }
public override int onThrow(ShapeBase player, int amount) { player.decInventory(this, 1); ObjectCreator tch = new ObjectCreator("ProximityMine", string.Empty); tch["datablock"] = getName(); tch["sourceObject"] = player; tch["rotation"] = new AngAxisF(0, 0, 1, (float) (new Random().NextDouble()*360)); tch["static"] = false; tch["client"] = player["client"]; ProximityMine pm = (tch.Create()); ((SimSet) "MissionCleanup").pushToBack(pm); return pm; }
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); } } }
public override void onWetFire(ShapeBase obj, int slot) { if (!this["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 (!this["infiniteAmmo"].AsBool()) obj.decInventory(this["ammo"], 1); // Get the player's velocity, we'll then add it to that of the projectile int numProjectiles = this["projectileNum"].AsInt(); if (numProjectiles == 0) numProjectiles = 1; TransformF muzzleVector = new TransformF(); for (int i = 0; i < numProjectiles; i++) { if (this["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.mPositionX = (float) ((r.NextDouble() - .5)*2*Math.PI*this["wetProjectileSpread"].AsFloat()); matrix.mPositionY = (float) ((r.NextDouble() - .5)*2*Math.PI*this["wetProjectileSpread"].AsFloat()); matrix.mPositionZ = (float) ((r.NextDouble() - .5)*2*Math.PI*this["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(this["wetProjectile.muzzleVelocity"].AsFloat()); objectVelocity = objectVelocity.vectorScale(this["wetProjectile.velInheritFactor"].AsFloat()); Point3F muzzleVelocity = muzzleVector.GetPosition() + objectVelocity; ObjectCreator tch = new ObjectCreator(this["projectileType"]); tch["dataBlock"] = this["wetProjectile"]; tch["initialVelocity"] = muzzleVelocity; tch["initialPosition"] = obj.getMuzzlePoint(slot); tch["sourceObject"] = obj; tch["sourceSlot"] = slot; tch["client"] = obj["client"]; tch["sourceClass"] = obj.getClassName(); Item projectile = tch.Create(); ((SimSet) "MissionCleanup").pushToBack(projectile); } }