public virtual bool onUse(ShapeBase user) { //// Invoked when the object uses this datablock, should return //// true if the item was used. return false; }
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 void onInventory(ShapeBase user, int value) { //Player can be either a player object or a aiturret... GameConnection client = user["client"]; for (int i = 0; i < 8; i++) { if (user.GetType() == typeof (Player)) { ShapeBaseImageData image = (user).getMountedImage(i); if (image <= 0) continue; if (!image["ammo"].isObject()) continue; if (((SimObject) image["ammo"]).getId() != this.getId()) continue; (user).setImageAmmo(i, value != 0); } else if (user.GetType() == typeof (AITurretShape)) { ShapeBaseImageData image = (user).getMountedImage(i); if (image <= 0) continue; if (!image["ammo"].isObject()) continue; if (((SimObject) image["ammo"]).getId() != getId()) continue; (user).setImageAmmo(i, value != 0); } int currentammo = user.getInventory(this); // ShapeBaseShapeBaseGetInventory(player, thisobj); if (user.getClassName() != "Player") continue; int amountInClips; if (this["clip"].isObject()) { amountInClips = user.getInventory(this["clip"]); // ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]); amountInClips *= this["maxInventory"].AsInt(); amountInClips += user["remaining" + getName()].AsInt(); } else { amountInClips = currentammo; currentammo = 1; } if (user["client"] != string.Empty && !user["isAiControlled"].AsBool()) client.setAmmoAmountHud(currentammo, amountInClips); } }
public virtual int onThrow(ShapeBase user, int amount) { // Invoked when the object is thrown. This method should // construct and return the actual mission object to be // physically thrown. This method is also responsible for // decrementing the user's inventory. return 0; }
public override bool onPickup(Item obj, ShapeBase user, int amount) { if (base.onPickup(obj, user, amount)) { Audio.AudioServerPlay3D("AmmoPickupSound", user.getTransform()); return true; } return false; }
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 virtual bool onPickup(Item obj, ShapeBase user, int amount) { // Invoked when the user attempts to pickup this datablock object. // The %amount argument is the space in the user's inventory for // this type of datablock. This method is responsible for // incrementing the user's inventory is something is addded. // Should return true if something was added to the inventory. 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 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 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 void onCollision(ShapeBase obj, SceneObject collObj, Point3F vec, float len) { if (!((collObj.GetType() == typeof (Player)) || (collObj.GetType() == typeof (AIPlayer)))) return; Player player = (Player) collObj; if (player.getDamageLevel() <= 0.00 || player.getState() == "Dead") return; player.applyRepair(this["repairAmount"].AsFloat()); player.setEnergyLevel(1); obj.schedule((100).AsString(), "startFade", "1000", "0", "true"); obj.schedule((1200).AsString(), "delete"); Audio.AudioServerPlay3D("HealthUseSound", player.getTransform()); }
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); } }
/*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 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 void onDisabled(ShapeBase obj, string lastState) { //console.print("### AI DEAD ###!"); Player npc = obj.ID; Util.cancelAll(npc); ScriptObject aimanager = null; aimanager = npc["aiManager"]; if (!aimanager.isObject()) { console.error("Bad aiManager"); return; } npc.setImageTarget(0, false); SimObject item = ((SimObject) npc.getMountedImage(iGlobal["$WeaponSlot"]))["item"]; if (item.isObject()) { //string item = console.GetVarString(ShapeBase.getMountedImage(npc, WeaponSlot).AsString() + ".item"); if (r.Next(1, 100) > 80) { int amount = npc.getInventory(item["image.ammo"]); if (amount.AsBool()) npc.Throw(item["image.clip"], 1); } } npc.tossPatch(); npc.playDeathCry(); npc.playDeathAnimation(); int ctov = 2000; if (AI.lastcount > 0) AI.spawnAI(aimanager); npc.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true"); Util._schedule("1", "0", "SafeDeleteCallback", npc); }
public override void onCollision(ShapeBase obj, SceneObject collObj, Point3F vec, float len) { // Collision with other objects, including items }
public virtual void onWetFire(ShapeBase obj, int slot) { }
public virtual void onInventory(ShapeBase thisobj, ModelBase data, string value) { // Invoked on ShapeBase objects whenever their inventory changes // for the given datablock. }
public virtual void teleFrag(GameBase player, Trigger exit) { // When a telefrag happens, there are two cases we have to consider. // The first case occurs when the player's bounding box is much larger than the exit location, // it is possible to have players colide even though a player is not within the bounds // of the trigger Because of this we first check a radius the size of a player's bounding // box around the exit location. // Get the bounding box of the player Point3F boundingBoxSize = new Point3F(((PlayerData)player.getDataBlock())["boundingBox"]); float radius = boundingBoxSize.x; float boxSizeY = boundingBoxSize.y; float boxSizeZ = boundingBoxSize.z; // Use the largest dimention as the radius to check if (boxSizeY > radius) { radius = boxSizeY; } if (boxSizeZ > radius) { radius = boxSizeZ; } Point3F position = exit.getTransform().GetPosition(); // new TransformF(con.getTransform(exit)); uint mask = (uint)SceneObjectTypesAsUint.PlayerObjectType; // Check all objects within the found radius of the exit location, and telefrag // any players that meet the conditions. Dictionary <uint, float> r = console.initContainerRadiusSearch(position, radius, mask); foreach ( ShapeBase objectNearExit in r.Keys.Where(objectNearExit => ((ShapeBase)objectNearExit).isMemberOfClass("Player")) .Where(objectNearExit => objectNearExit.AsString() != player)) { objectNearExit.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag"); } // The second case occurs when the bounds of the trigger are much larger // than the bounding box of the player. (So multiple players can exist within the // same trigger). For this case we check all objects contained within the trigger // and telefrag all players. int objectsInExit = exit.getNumObjects(); // Loop through all objects in the teleporter exit // And kill any players for (int i = 0; i < objectsInExit; i++) { ShapeBase objectInTeleporter = console.Call(exit, "getObject", new[] { i.AsString() }); if (objectInTeleporter.isMemberOfClass("Player")) { continue; } // Avoid killing the player that is teleporting in the case of two // Teleporters near eachother. if (objectInTeleporter == player) { continue; } objectInTeleporter.damage(player, exit.getTransform().GetPosition(), 10000, "Telefrag"); } }
public virtual void damage(ShapeBase obj, Point3F position, GameBase source, float damage, string damagetype) { // Ignore damage by default. This empty method is here to // avoid console warnings. }
public override void damage(ShapeBase obj, Point3F position, GameBase source, float damage, string damagetype) { // Explode if any damage is applied to the mine int r = 50 + (new Random().Next(0, 50)); schedule(r.AsString(), "explode"); }
public override void onInventory(ShapeBase obj, int amount) { GameConnection client = obj["client"]; if (client.isObject()) client.setAmmoAmountHud(1, amount); //todo Something funny here, probally should look at it. if (amount == 0) obj.cycleWeapon("prev"); }
public override void onCollision(ShapeBase obj, SceneObject col, Point3F vec, float len) { Player player = obj.getId(); if (player.getState() == "Dead") { return; } // Try and pickup all items if (col.getClassName() == "Item") { player.pickup(col.ID, 1); return; } if (col.GetType() != typeof(WheeledVehicle)) { return; } WheeledVehicle vcol = (WheeledVehicle)col; //AI are not allowed to drive they are lousey drivers.... GameConnection client = player["client"]; if (!client.isObject()) { return; } //Mount Vehicle. if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) { return; } VehicleData db = vcol.getDataBlock(); if ( !(((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool()))) { return; } // Only mount drivers for now. // For this specific example, only one person can fit // into a vehicle int mount = vcol.getMountNodeObject(0); if (mount > 0) { try { Player p = mount; return; } catch (Exception err) { //Water particle emitters seem to take up the seat when the vehicle is in water. vcol.unmountObject(mount.AsString()); vcol.mountObject(player, 0, new TransformF()); ((GameConnection)player["client"]).setFirstPerson(false); console.commandToClient(client, "PushVehicleMap"); } } else { vcol.mountObject(player, 0, new TransformF()); ((GameConnection)player["client"]).setFirstPerson(false); console.commandToClient(client, "PushVehicleMap"); } //if (mount > 0) //return; // For this specific FPS Example, always mount the player to node 0 player["mVehicle"] = col; }
public void setDamageDirection(GameBase sourceObject, TransformF damagePos) { if (sourceObject.isObject()) { damagePos = console.isField(sourceObject, "initialPosition") ? new TransformF(sourceObject["initialPosition"]) : sourceObject.getTransform(); } TransformF dp = damagePos; Point3F wbc = getWorldBoxCenter(); TransformF damagevec = dp - new TransformF(wbc); damagevec = damagevec.normalizeSafe(); GameConnection client = this["client"]; if (!client.isObject()) { return; } ShapeBase cameraobject = client.getCameraObject(); TransformF inverseTransform = cameraobject.getInverseTransform(); damagevec = math.MatrixMulVector(inverseTransform, damagevec.GetPosition()); float[] components = new float[6]; string[] directions = new string[6]; directions[0] = "Left"; directions[1] = "Right"; directions[2] = "Bottom"; directions[3] = "Front"; directions[4] = "Bottom"; directions[5] = "Top"; components[0] = -damagevec.mPositionX; components[1] = damagevec.mPositionX; components[2] = -damagevec.mPositionY; components[3] = damagevec.mPositionY; components[4] = -damagevec.mPositionZ; components[5] = damagevec.mPositionZ; string damagedirection = string.Empty; float max = 0; for (int i = 0; i < 6; i++) { if (components[i] <= max) { continue; } damagedirection = directions[i]; max = components[i]; } if (console.isObject(client)) { // Util._commandToClient(client, console.addTaggedString("setDamageDirection"), damagedirection); console.commandToClient(client, console.addTaggedString("setDamageDirection"), new[] { damagedirection }); } }
public virtual void onInventory(ShapeBase user, int value) { }
public override void onInventory(ShapeBase user, int value) { }
public override bool onUse(ShapeBase user) { return(false); }
public override void onTrigger(ShapeBase obj, int index, bool state) { WheeledVehicle vehicle = obj._ID; // Pass trigger states on to TurretImage (to fire weapon) switch (index) { case 0: vehicle.setImageTrigger(this["turretSlot"].AsInt(), state); break; case 1: vehicle.setImageAltTrigger(this["turretSlot"].AsInt(), state); break; } }
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 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 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 override void onDamage(ShapeBase obj, float delta) { // This method is invoked by the ShapeBase code whenever the // object's damage level changes. }
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; }
public override void onEnabled(ShapeBase obj, string lastState) { // This method is invoked by the ShapeBase code whenever the // object's damage state changes. }
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 void onTrigger(ShapeBase obj, int index, bool state) { // This method is invoked when the player receives a trigger move event. // The player automatically triggers slot 0 and slot one off of triggers # // 0 & 1. Trigger # 2 is also used as the jump key. }
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 void onImageUnmount(ShapeBase obj, int slot, float dt) { GameConnection client = obj["client"]; if (client != string.Empty && obj["isAiControlled"].AsBool()) client.refreshWeaponHud(0, string.Empty, string.Empty, string.Empty, 0); }
public override void onInventory(ShapeBase obj, int amount) { if (amount != 0 || !obj.isMethod("getMountSlot")) return; int slot = obj.getMountSlot(this["image"]); obj.unmountImage(slot); }
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); } }
public virtual void onClipEmpty(ShapeBase obj, int slot) { this.schedule("0", "reloadAmmoClip", obj, slot.AsString()); }