public void WeaponImageOnMount(coScriptObject thisobj, coPlayer player, int slot) { coGameConnection client = player["client"]; string ammoName = ""; ammoName = ((coItemData)thisobj["ammo"]).getName(); int currentammo = 0; int ammountinClips = 0; if (thisobj.isField("clip")) { if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool()) { player.setImageAmmo(slot, true); currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]); } else if (ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]) > 0) { ShapeBaseShapeBaseSetInventory(player, thisobj["ammo"], thisobj["ammo.maxInventory"].AsInt()); player.setImageAmmo(slot, true); currentammo = thisobj["ammo.maxInventory"].AsInt(); ammountinClips += player["remaining" + ammoName].AsInt(); } else { ammountinClips += player["remaining" + ammoName].AsInt(); } ammountinClips = ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]); ammountinClips *= thisobj["ammo.maxInventory"].AsInt(); if ((player["client"] != "") && !player["isAiControlled"].AsBool()) { GameConnectionRefreshWeaponHud(client, currentammo, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], ammountinClips); } } else if (thisobj["ammo"] != "") { if (ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]).AsBool()) { player.setImageAmmo(slot, true); currentammo = ShapeBaseShapeBaseGetInventory(player, thisobj["ammo"]); } else { currentammo = 0; } if (player["client"] != "" && !player["isAiControlled"].AsBool()) { GameConnectionRefreshWeaponHud(client, 1, thisobj["item.previewImage"], thisobj["item.reticle"], thisobj["item.zoomReticle"], currentammo); } } }
public void WeaponImageOnUnmount(coScriptObject thisobj, coPlayer player, int slot) { coGameConnection client = player["client"]; if (client != "" && player["isAiControlled"].AsBool()) { GameConnectionRefreshWeaponHud(client, 0, "", "", "", 0); } }
public void spawnAI(coScriptObject aiManager) { if (!console.isObject(aiManager)) { console.error("Bad aiManager!"); return; } coAIPlayer aiPlayer = AiPlayerSpawnOnPath("Team" + aiManager["aiteam"], "MissionGroup/Paths/team" + aiManager["aiteam"] + "Path"); if (aiPlayer == null) { console.error("UNABLE TO SPAWN MONSTER!@!!!!!a"); aiManager.schedule("1000", "0", "spawnai", aiManager); return; } if (!console.isObject(aiPlayer)) { console.error("UNABLE TO SPAWN MONSTER!@!!!!!"); aiManager.schedule("1000", "0", "spawnai", aiManager); return; } // m_ts.LogError("AIManager " + aiManager + " - Creating."); aiPlayer.call("FollowPath", "MissionGroup/Paths/team" + aiManager["aiteam"] + "Path", "-1"); aiPlayer.setMoveSpeed(0.8f); aiManager["player"] = aiPlayer; aiPlayer["aiManager"] = aiManager; aiPlayer["aiteam"] = aiManager["aiteam"]; ShapeBaseShapeBaseSetInventory(aiPlayer, "Lurker", 1); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerClip", 1000); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerAmmo", 1000); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerGrenadeLauncher", 1); ShapeBaseShapeBaseSetInventory(aiPlayer, "LurkerGrenadeAmmo", 10); ShapeBaseShapeBaseSetInventory(aiPlayer, "ProxMine", 5); ShapeBaseShapeBaseSetInventory(aiPlayer, "DeployableTurret", 5); aiPlayer.mountImage("LurkerWeaponImage", 0, true, ""); TransformF t = aiPlayer.getTransform(); t.MPosition.z += r.Next(0, 200); aiPlayer.setTransform(t); AddObjectTo_MobSearchGroup(aiPlayer, aiManager["aiteam"].AsInt()); m_thoughtqueue.Add(new AIInterval(DateTime.Now.AddMilliseconds(500), aiPlayer)); //AIPlayerThink(aiPlayer, aiPlayer); //aiPlayer.schedule("100", "think", aiPlayer); aiscreated++; }
public void WeaponOnInventory(coScriptObject thisobj, coShapeBase obj, int amount) { if (amount != 0 || !obj.isMethod("getMountSlot")) { return; } int slot = obj.getMountSlot(thisobj["image"]); obj.unmountImage(slot); }
public void deleteAI() { for (int i = 0; i < lastcount; i++) { coScriptObject mobholder = "Mob" + i.AsString(); mobholder["player"].delete(); mobholder.delete(); } lastcount = 0; }
public void WeaponOnPickup(coScriptObject thisobj, string obj, coShapeBase shape, int amount, int nameSpaceDepth) { int nsd = (nameSpaceDepth + 1); if (!console.ParentExecute(thisobj, "onPickup", nsd, new string[] { thisobj, obj, shape, amount.AsString() }).AsBool()) { return; } AudioServerPlay3D("WeaponPickupSound", shape.getTransform()); if (shape.getClassName() == "Player" && shape.getMountedImage(WeaponSlot) == 0) { shape.call("use", thisobj); } }
public void DemoPlayerOnDisabled(coPlayerData datablock, coAIPlayer npc, string state) { Util._cancelAll(npc); coScriptObject aimanager = null; aimanager = npc["aiManager"]; if (!aimanager.isObject()) { console.error("Bad aiManager"); return; } npc.setImageTarget(0, false); coSimObject item = ((coSimObject)npc.getMountedImage(WeaponSlot))["item"]; if (item.isObject()) { //string item = console.GetVarString(ShapeBase.getMountedImage(npc, WeaponSlot).AsString() + ".item"); if (r.Next(1, 100) > 80) { int amount = ShapeBaseShapeBaseGetInventory(npc, item["image.ammo"]); if (amount.AsBool()) { ShapeBaseShapeBaseThrow(npc, item["image.clip"], 1); } } } ShapeBaseTossPatch(npc); PlayerPlayDeathCry(npc); PlayerPlayDeathAnimation(npc); int ctov = 2000; spawnAI(aimanager); npc.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true"); npc.schedule(ctov.AsString(), "deleteme"); aiscreated--; }
public void WeaponOnUser(coScriptObject data, coPlayer obj) { if (obj.getMountedImage(WeaponSlot) == data["image"].AsInt()) { return; } AudioServerPlay3D("WeaponUseSound", obj.getTransform()); obj.mountImage(data["image"], WeaponSlot, true, ""); if (obj["client"].AsBool()) { if (data["description"] != "") { MessageClient(obj["client"], "MsgWeaponUsed", "\\c3%1 \\c5 selected.", data["description"]); } else { MessageClient(obj["client"], "MsgWeaponUsed", console.addTaggedString(@"\c0Weapon selected")); } } if (obj.isInNamespaceHierarchy("Player")) { return; } obj.allowAllPoses(); coSimObject image = data["image"]; if (image["jumpingDisallowed"].AsBool()) { obj.allowJumping(false); } if (image["jetJumpingDisallowed"].AsBool()) { obj.allowJetJumping(false); } if (image["sprintDisallowed"].AsBool()) { obj.allowSprinting(false); } if (image["crouchDisallowed"].AsBool()) { obj.allowCrouching(false); } if (image["proneDisallowed"].AsBool()) { obj.allowProne(false); } if (image["swimmingDisallowed"].AsBool()) { obj.allowSwimming(false); } }
public void WeaponImageOnClipEmpty(coScriptObject thisobj, coPlayer obj, int slot) { thisobj.schedule("0", "reloadAmmoClip", obj, slot.AsString()); }
public void WeaponImageonWetFire(coScriptObject thisobj, coPlayer obj, int slot) { if (!thisobj["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 (!thisobj["infiniteAmmo"].AsBool()) { ShapeBaseShapeBaseDecInventory(obj, thisobj["ammo"], 1); } // Get the player's velocity, we'll then add it to that of the projectile int numProjectiles = thisobj["projectileNum"].AsInt(); if (numProjectiles == 0) { numProjectiles = 1; } TransformF muzzleVector = new TransformF(); for (int i = 0; i < numProjectiles; i++) { if (thisobj["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.MPosition.x = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat()); matrix.MPosition.y = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat()); matrix.MPosition.z = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["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(thisobj["wetProjectile.muzzleVelocity"].AsFloat()); objectVelocity = objectVelocity.vectorScale(thisobj["wetProjectile.velInheritFactor"].AsFloat()); Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity; Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"]); tch.Props.Add("dataBlock", thisobj["wetProjectile"]); tch.Props.Add("initialVelocity", '"' + muzzleVelocity.AsString() + '"'); tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot).AsString() + '"'); tch.Props.Add("sourceObject", obj); tch.Props.Add("sourceSlot", slot.AsString()); tch.Props.Add("client", obj["client"]); tch.Props.Add("sourceClass", obj.getClassName()); coItem projectile = tch.Create(); ((coSimSet)"MissionCleanup").pushToBack(projectile); } }