public void ArmorOnDisabled(coPlayerData datablock, coPlayer player, string state) { player.setImageTrigger(0, false); coItem item = (((coItemData)(player.getMountedImage(WeaponSlot)))["item"]); if (item.isObject()) { int amount = ShapeBaseShapeBaseGetInventory(player, (item["image.ammo"])); if (amount.AsBool()) { ShapeBaseShapeBaseThrow(player, (item["image.clip"]), 1); } } ShapeBaseTossPatch(player); PlayerPlayDeathCry(player); PlayerPlayDeathAnimation(player); //If it's a player check..... coGameConnection client = player["client"]; if (client.isObject()) { console.commandToClient(client, console.addTaggedString("toggleVehicleMap"), new[] { "false" }); } int ctov = iGlobal["$CorpseTimeoutValue"]; player.schedule((ctov - 1000).AsString(), "startFade", "1000", "0", "true"); player.schedule(ctov.AsString(), "delete"); }
public void ArmorOnRemove(coPlayerData datablock, coPlayer player) { if (player["client.player"] == player) { player["client.player"] = "0"; } }
public void ArmorOnAdd(coPlayerData datablock, coPlayer player) { player["mountVehicle"] = true.AsString(); player.setRechargeRate(datablock["rechargeRate"].AsFloat()); player.setRepairRate(0); //player.schedule("50", "updateHealth"); }
public void ArmorOnImpact(coPlayerData datablock, coPlayer player, coShapeBase collidedObject, TransformF vec, float vecLen) { TransformF p = player.getTransform(); p = p + vec; float speedDamageScale = vecLen + datablock["speedDamageScale"].AsFloat(); ShapeBaseDamage(player, "0", p.MPosition, speedDamageScale, "Impact"); }
public void ArmorDamage(coPlayerData datablock, coPlayer player, TransformF position, coPlayer sourceobject, float damage, string damageType) { if (!player.isObject()) { return; } if (player.getState() == "Dead") { return; } if (damage == 0.0) { return; } player.applyDamage(damage); const string location = "Body"; //PlayerUpdateHealth(player); coGameConnection client = player["client"]; //Only continue if it is a player, if it is an AI return. if (!client.isObject()) { return; } coGameConnection sourceClient = null; if (sourceobject != 0) { sourceClient = sourceobject["client"]; } if (player.getDamageLevel() >= 99) { player.unmountImage(0); } // Determine damage direction if (damageType != "Suicide") { PlayerSetDamageDirection(player, sourceobject, position); } if (player.getState() == "Dead") { GameConnectionOnDeath(client, sourceobject, sourceClient, damageType, location); } }
public void DemoPlayerOnMoveStuck(coPlayerData datablock, coAIPlayer npc) { coSimSet path = npc["path"]; uint targetnode = datablock["targetNode"].AsUint(); coMarker node = path.getObject(targetnode); TransformF t = node.getTransform(); t.MPosition.z += r.Next(10, 100); t.MPosition.x += r.Next(10, 30); t.MPosition.y += r.Next(10, 30); npc.setTransform(t); }
public void ArmorOnDamage(coPlayerData datablock, coPlayer player, float delta) { // This method is invoked by the ShapeBase code whenever the // object's damage level changes. if ((delta <= 0) || player.getState() == "Dead") { return; } // Apply a damage flash player.setDamageFlash(1); // If the pain is excessive, let's hear about it. if (delta > 10) { PlayerPlayPain(player); } }
public void DemoPlayerDamage(coPlayerData datablock, coAIPlayer npc, string position, coPlayer sourceobject, float damage, string damageType) { if (!npc.isObject()) { return; } if (npc.getState() == "Dead") { return; } if (damage == 0.0) { return; } npc.applyDamage(damage); if (npc.getState() == "Dead") { return; } Point3F ejectvel = npc.getVelocity(); if (ejectvel.z <= 0) { ejectvel += new Point3F(0, 0, 5); ejectvel = ejectvel.vectorScale(datablock["mass"].AsFloat()); npc.applyImpulse(npc.getPosition(), ejectvel); } Point3F currentpos = npc.getPosition(); currentpos.x += r.Next(-5, 5); currentpos.y += r.Next(-5, 5); if (npc.getDamageLevel() > 50) { currentpos.x += r.Next(-50, 50); currentpos.y += r.Next(-50, 50); } npc.setMoveDestination(currentpos, false); }
public void ArmorOnCollision(coPlayerData datablock, coPlayer player, coShapeBase col) { if (player.getState() == "Dead") { return; } // Try and pickup all items if (col.getClassName() == "Item") { player.call("pickup", col); return; } //AI are not allowed to drive they are lousey drivers.... coGameConnection client = player["client"]; if (!client.isObject()) { return; } //Mount Vehicle. if ((console.getTypeMask(col) & (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) != (UInt32)SceneObjectTypesAsUint.GameBaseObjectType) { return; } coVehicleData db = col.getDataBlock(); if (((db.getClassName() == "WheeledVehicleData") || player["mountVehicle"].AsBool() || player.getState() == "Move" || col["mountable"].AsBool())) { return; } // Only mount drivers for now. ((coGameConnection)player["client"]).setFirstPerson(false); // For this specific example, only one person can fit // into a vehicle int mount = col.getMountNodeObject(0); if (mount > 0) { return; } // For this specific FPS Example, always mount the player to node 0 col.mountObject(player, 0, new TransformF(true)); player["mVehicle"] = col; }
public void DemoPlayerOnReachDestination(coPlayerData datablock, coAIPlayer npc) { if (npc["HoldAndFire"].AsBool()) { return; } if (npc["path"] == "") { return; } if (npc["currentNode"] == npc["targetNode"]) { DemoPlayerOnEndOfPath(datablock, npc, npc["path"]); } else { AiPlayerMoveToNextNode(npc); } }
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 ArmorOnUnmount(coPlayerData datablock, coPlayer player, coVehicle vehicle, int node) { if (node != 0) { return; } player.mountImage(player["lastWeapon"], WeaponSlot, true, ""); player.setControlObject(""); if (!player["lastperson"].AsBool()) { return; } coGameConnection client = player["client"]; if (client.isObject()) { client.setFirstPerson(player["lastperson"].AsBool()); } }
public void ServerCmdMissionStartPhase2Ack(coGameConnection client, string seq, coPlayerData playerDB) { // Make sure to ignore calls from a previous mission load if (seq != sGlobal["$missionSequence"] || !missionRunning) { return; } if (client["currentPhase"].AsDouble() != 1.5) { return; } client["currentPhase"] = "2"; // Set the player datablock choice client["playerDB"] = playerDB; // Update mod paths, this needs to get there before the objects. client.transmitPaths(); // Start ghosting objects to the client client.activateGhosting(); }
public void ArmorOnMount(coPlayerData datablock, coPlayer player, coVehicle vehicle, int node) { coVehicleData vehicleDataBlock = vehicle.getDataBlock(); if (node == 0) { player.setTransform(new TransformF("0 0 0 0 0 1 0")); string mountPose = vehicleDataBlock["mountPose[" + node + "]"]; player.setActionThread(mountPose, true, true); player["lastWeapon"] = player.getMountedImage(WeaponSlot).AsString(); coGameConnection client = player["client"]; if (client.isObject()) { player["lastperson"] = client.isFirstPerson().AsString(); } player.unmountImage(WeaponSlot); player.setControlObject(vehicle); if (player.getClassName() == "Player") { console.commandToClient(player["client"], console.addTaggedString("toggleVehicleMap"), new[] { "true" }); } } else { string pose = vehicleDataBlock["mountPose[" + node + "]"]; player.setActionThread(pose != "" ? pose : "root", false, true); } }
public void DemoPlayerOnTargetExitLos(coPlayerData datablock, coAIPlayer npc) { npc.setImageTrigger(0, false); }
public void ArmorOnStopSprintMotion(coPlayerData datablock, coPlayer player) { player.setImageGenericTrigger(WeaponSlot, 0, false); }
public void ArmorOnPosechange(coPlayerData datablock, coPlayer player, string oldpose, string newpose) { player.setImageScriptAnimPrefix(WeaponSlot, console.addTaggedString(newpose)); }
public void ArmorOnTrigger(coPlayerData datablock, coPlayer player, string triggernum, string val) { // 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 void ArmorOnLeaveLiquid(coPlayerData datablock, coPlayer player, string type) { }
public void ArmorOnEnterLiquid(coPlayerData datablock, coPlayer player, string coverage, string type) { }
public void ArmorOnEnterMissionArea(coPlayerData datablock, coPlayer player) { GameConnectionOnEnterMissionArea(player["client"]); }
public void DemoPlayerOnTargetEnterLos(coPlayerData datablock, coAIPlayer npc) { npc.setImageTrigger(0, true); }
public void DemoPlayerOnEndOfPath(coPlayerData datablock, coAIPlayer npc, string path) { AiPlayerNextTask(npc); }
public void DemoPlayerOnEndSequence(coPlayerData datablock, coAIPlayer npc, int slot) { npc.stopThread(slot); AiPlayerNextTask(npc); }
public void ArmorOnNewDataBlock(coPlayerData datablock, coPlayer player) { }
public void ArmorDoDismount(coPlayerData datablock, coPlayer player, bool forced) { coVehicle vehicle = player["mVehicle"]; if (!vehicle.isObject()) { return; } if (!player.isMounted()) { return; } Point3F vvel = vehicle.getVelocity(); coVehicleData vdb = vehicle.getDataBlock(); int maxDismountSpeed = vdb["maxDismountSpeed"].AsInt(); if ((vvel.len() <= maxDismountSpeed) || (forced)) { TransformF pos = player.getTransform(); TransformF rot = pos; TransformF oldpos = pos.copy(); List <Point3F> vecs = new List <Point3F> { new Point3F(-1, 0, 0), new Point3F(0, 0, 1), new Point3F(0, 0, -1), new Point3F(1, 0, 0), new Point3F(0, -1, 0), new Point3F(0, 0, 0) }; Point3F impulsevec = new Point3F(0, 0, 0); TransformF r = math.MatrixMulVector(player.getTransform(), vecs[0]); vecs[0] = r.MPosition; pos.MPosition.x = 0; pos.MPosition.y = 0; pos.MPosition.z = 0; const int numofAttempts = 5; int success = -1; for (int i = 0; i < numofAttempts; i++) { Point3F vectorscale = vecs[i].vectorScale(3); pos = oldpos + new TransformF(vectorscale); if (!player.checkDismountPoint(oldpos.MPosition, pos.MPosition)) { continue; } success = i; impulsevec = vecs[i].copy(); break; } if ((forced) && (success == -1)) { pos = oldpos.copy(); } player["mountVehicle"] = false.AsString(); player.schedule("4000", "mountVehicles", "true"); player.unmount(); player.setTransform(new TransformF(pos.MPosition.x, pos.MPosition.y, pos.MPosition.z, rot.MOrientation.x, rot.MOrientation.y, rot.MOrientation.z, rot.MAngle)); Point3F velo = impulsevec.vectorScale(player["mass"].AsFloat()); velo.z = 1; player.applyImpulse(pos.MPosition, velo); Point3F vel = player.getVelocity(); float vec = Point3F.vectorDot(vel, vel.normalizeSafe()); if (vec > 50) { float scale = 50 / vec; player.setVelocity(vel.vectorScale(scale)); } } else { MessageClient(player["client"], "msgUnmount", @"\c2Cannot exit %1 while moving.", console.GetVarString(vdb + ".nameTag")); } }