Esempio n. 1
0
        public override void damage(ShapeBase obj, Point3F position, GameBase sourceobject, float damage, string damagetype)
        {
            Player pobj = obj._ID;

            if (!pobj.isObject() || pobj.getState() == "Dead" || !damage.AsBool())
            {
                return;
            }

            obj.applyDamage(damage);

            GameConnection client = obj["client"];

            if (!client.isObject())
            {
                return;
            }
            if (damagetype != "Suicide")
            {
                pobj.setDamageDirection(sourceobject, new TransformF(position));
            }

            if (pobj.getState() == "Dead")
            {
                client.onDeath(sourceobject, sourceobject["client"].isObject() ? sourceobject["client"] : "0", damagetype, "Body");
            }
        }
Esempio n. 2
0
        public override void onDamage(ShapeBase obj, float delta)
        {
            Player player = obj.getId();

            // 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)
            {
                player.playPain();
            }
        }
Esempio n. 3
0
        public virtual int GetNearestPlayerTarget()
        {
            if (!isObject())
            {
                return(-1);
            }

            if ((this["CurrentTarget"] != "") && (this["CurrentTarget"] != "-1"))
            {
                if (this["CurrentTarget"].isObject())
                {
                    if (((Player)this["CurrentTarget"]).getState() != "Dead")
                    {
                        if (TargetIsInLos(this["CurrentTarget"]))
                        {
                            return(this["CurrentTarget"].AsInt());
                        }
                    }
                }

                this["CurrentTarget"] = "";
            }

            SimSet mobSearchGroup = this["aiteam"] == "1" ? "MobSearchGroup_2" : "MobSearchGroup_1";

            SimSet mobSearchGroupResult = "MobSearchGroupResult";

            if (!mobSearchGroupResult.isObject())
            {
                mobSearchGroupResult = new ObjectCreator("SimSet", "MobSearchGroupResult").Create();
            }

            AISearchSimSet(180, 50, mobSearchGroup, mobSearchGroupResult);

            int   closesttarget = -1;
            float closestdist   = 51;

            for (uint i = 0; i < mobSearchGroupResult.getCount(); i++)
            {
                Player target = mobSearchGroupResult.getObject(i);
                if (!target.isObject())
                {
                    continue;
                }
                if (target.getState() == "Dead")
                {
                    continue;
                }
                float dist = GetTargetDistance(target);
                if (dist >= closestdist)
                {
                    continue;
                }
                closestdist   = dist;
                closesttarget = target;
            }
            mobSearchGroupResult.clear();

            this["CurrentTarget"] = closesttarget.AsString();

            return(closesttarget);
        }
Esempio n. 4
0
        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;
        }