Example #1
0
        public virtual string pickCameraSpawnPoint(string spawnGroups)
        {
            SimObject spawnpoint = null;

            String[] lspawngroups = spawnGroups.Split(' ');

            foreach (SimSet group in lspawngroups)
            {
                if (!group.isObject())
                {
                    continue;
                }
                spawnpoint = group.getRandom();
                if (spawnpoint.isObject())
                {
                    return(spawnpoint);
                }
            }
            SpawnSphere DefaultCameraSpawnSphere = "DefaultCameraSpawnSphere";

            if (!DefaultCameraSpawnSphere.isObject())
            {
                ObjectCreator spawn = new ObjectCreator("SpawnSphere", "DefaultCameraSpawnSphere");
                spawn["dataBlock"]      = "SpawnSphereMarker";
                spawn["spawnClass"]     = sGlobal["$Game::DefaultCameraClass"];
                spawn["spawnDatablock"] = sGlobal["$Game::DefaultCameraDataBlock"];
                SpawnSphere spawnobj = spawn.Create();

                ((SimSet)"MissionCleanup").pushToBack(spawnobj);
            }

            return(DefaultCameraSpawnSphere);
        }
 public virtual bool hasHumanRider()
 {
     for (int i = 0; i < this.getNumAttachments(); i++)
     {
         SimObject remainingObj = this.getAttachment(i);
         if (remainingObj.isObject() && remainingObj["client"].isObject() && remainingObj["client.player"] == remainingObj)
         {
             return(true);
         }
     }
     return(false);
 }
        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 onEnterTrigger(Trigger trigger, GameBase obj)
        {
            //if (!console.isMemberOfClass(obj, "Player"))
            //    return;

            if (obj["isTeleporting"].AsBool())
            {
                return;
            }
            // Get the location of our target position
            Trigger exit = trigger["exit"];

            bool valid = verifyObject(obj, trigger, exit);

            if (!valid)
            {
                return;
            }

            teleFrag(obj, exit);
            // Create our entrance effects on all clients.

            SimObject entranceeffect = trigger["entranceEffect"];

            if (entranceeffect.isObject())
            {
                foreach (GameConnection client in ClientGroup)
                {
                    if (console.isObject(client))
                    {
                        console.commandToClient(client, "PlayTeleportEffect", new[] { trigger["position"], entranceeffect.getId().AsString() });
                    }
                }
            }

            teleportPlayer(obj, exit);
            // Create our exit effects on all clients.

            SimObject exitEffect = trigger["exitEffect"];

            if (exitEffect.isObject())
            {
                foreach (GameConnection client in ClientGroup)
                {
                    if (console.isObject(client))
                    {
                        console.commandToClient(client, "PlayTeleportEffect", new[] { trigger["position"], exitEffect.getId().AsString() });
                    }
                }
            }

            // Record what time we last teleported so we can determine if enough
            // time has elapsed to teleport again
            int tolt = console.getSimTime();

            trigger["timeOfLastTeleport"] = tolt.AsString();

            // If this is a bidirectional teleporter, log it's exit too.
            if (exit["exit"] == trigger["name"])
            {
                exit["timeOfLastTeleport"] = tolt.AsString();
            }

            // Tell the client to play the 2D sound for the player that teleported.
            if (((SimObject)this["teleportSound"]).isObject() && ((GameConnection)obj["client"]).isObject())
            {
                ((GameConnection)obj["client"]).play2D(this["teleportSound"]);
                //GameConnection.play2D(obj, thisobj["teleportSound"]);
            }
        }