Пример #1
0
        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");
        }
Пример #2
0
 public void ArmorOnRemove(coPlayerData datablock, coPlayer player)
 {
     if (player["client.player"] == player)
     {
         player["client.player"] = "0";
     }
 }
Пример #3
0
 public void ArmorOnAdd(coPlayerData datablock, coPlayer player)
 {
     player["mountVehicle"] = true.AsString();
     player.setRechargeRate(datablock["rechargeRate"].AsFloat());
     player.setRepairRate(0);
     //player.schedule("50", "updateHealth");
 }
Пример #4
0
        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");
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
 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);
     }
 }
Пример #8
0
        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);
        }
Пример #9
0
        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;
        }
Пример #10
0
 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);
     }
 }
Пример #11
0
        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--;
        }
Пример #12
0
        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());
            }
        }
Пример #13
0
        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();
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
 public void DemoPlayerOnTargetExitLos(coPlayerData datablock, coAIPlayer npc)
 {
     npc.setImageTrigger(0, false);
 }
Пример #16
0
 public void ArmorOnStopSprintMotion(coPlayerData datablock, coPlayer player)
 {
     player.setImageGenericTrigger(WeaponSlot, 0, false);
 }
Пример #17
0
 public void ArmorOnPosechange(coPlayerData datablock, coPlayer player, string oldpose, string newpose)
 {
     player.setImageScriptAnimPrefix(WeaponSlot, console.addTaggedString(newpose));
 }
Пример #18
0
 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.
 }
Пример #19
0
 public void ArmorOnLeaveLiquid(coPlayerData datablock, coPlayer player, string type)
 {
 }
Пример #20
0
 public void ArmorOnEnterLiquid(coPlayerData datablock, coPlayer player, string coverage, string type)
 {
 }
Пример #21
0
 public void ArmorOnEnterMissionArea(coPlayerData datablock, coPlayer player)
 {
     GameConnectionOnEnterMissionArea(player["client"]);
 }
Пример #22
0
 public void DemoPlayerOnTargetEnterLos(coPlayerData datablock, coAIPlayer npc)
 {
     npc.setImageTrigger(0, true);
 }
Пример #23
0
 public void DemoPlayerOnEndOfPath(coPlayerData datablock, coAIPlayer npc, string path)
 {
     AiPlayerNextTask(npc);
 }
Пример #24
0
 public void DemoPlayerOnEndSequence(coPlayerData datablock, coAIPlayer npc, int slot)
 {
     npc.stopThread(slot);
     AiPlayerNextTask(npc);
 }
Пример #25
0
 public void ArmorOnNewDataBlock(coPlayerData datablock, coPlayer player)
 {
 }
Пример #26
0
        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"));
            }
        }