public void VehicleDataOnAdd(coVehicleData thisobj, coVehicle obj)
        {
            obj.setRechargeRate(thisobj["rechargeRate"].AsFloat());
            obj.setEnergyLevel(thisobj["MaxEnergy"].AsFloat());
            obj.setRepairRate(0);

            {
                if (obj["mountable"].AsBool() || (obj["mountable"] == ""))
                {
                    VehicleDataIsMountable(thisobj, obj, true);
                }
                else
                {
                    VehicleDataIsMountable(thisobj, obj, false);
                }
            }


            string nametag = thisobj["nameTag"];


            if (nametag.Trim() != "")
            {
                obj.setShapeName(nametag);
            }
        }
Example #2
0
        public void ServerCmddismountVehicle(coGameConnection client)
        {
            coPlayer  player    = client["player"];
            coVehicle car       = player.getControlObject();
            coPlayer  passenger = car.getMountNodeObject(0);

            ((coSimDataBlock)passenger.getDataBlock()).call("doDismount", passenger, true.AsString());
            client.setControlObject(player);
        }
 public void VehicleDataMountPlayer(coVehicleData thisobj, coVehicle vehicle, coPlayer player)
 {
     if (!vehicle.isObject() || vehicle.getDamageState() == "Destroyed")
     {
         return;
     }
     player.startFade(1000, 0, true);
     thisobj.schedule("1000", "setMountVehicle", vehicle, player);
     player.schedule("1500", "startFade", "1000", "0", "false");
 }
 public int VehicleDataFindEmptySeat(coVehicleData thisobj, coVehicle vehicle, coPlayer player)
 {
     for (int i = 0; i < thisobj["numMountPoints"].AsInt(); i++)
     {
         int node = vehicle.getMountNodeObject(i);
         if (node != 0)
         {
             return(i);
         }
     }
     return(-1);
 }
 public void VehicleDataOnRemove(coVehicleData thisobj, coVehicle obj)
 {
     // if there are passengers/driver, kick them out
     for (int i = 0; i < ((coVehicleData)obj.getDataBlock())["numMountPoints"].AsInt(); i++)
     {
         coPlayer passenger = obj.getMountNodeObject(i);
         if (passenger != "0")
         {
             passenger.call("doDismount", true.AsString());
         }
     }
 }
Example #6
0
        public bool PlayerIsPilot(coPlayer player)
        {
            coVehicle vehicle = player.getObjectMount();

            if (vehicle.isObject())
            {
                if (vehicle.getMountNodeObject(0) == player)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #7
0
        public void ServerCmdflipCar(coGameConnection client)
        {
            coPlayer player = client["player"];

            coVehicle car = player.getControlObject();

            if (car.getClassName() != "WheeledVehicle")
            {
                return;
            }
            TransformF carpos = car.getTransform();

            carpos += new TransformF(0, 0, 3);
            car.setTransform(carpos);
        }
 public int VehicleDataSwitchSeats(coVehicleData thisobj, coVehicle vehicle, coPlayer player)
 {
     for (int i = 0; i < thisobj["numMountPoints"].AsInt(); i++)
     {
         int node = vehicle.getMountNodeObject(i);
         if (node == player || node > 0)
         {
             continue;
         }
         if (node == 0)
         {
             return(i);
         }
     }
     return(-1);
 }
        public void VehicleDataSetMountVehicle(coVehicleData thisobj, coVehicle vehicle, coPlayer player)
        {
            if (!vehicle.isObject() || vehicle.getDamageState() == "Destroyed")
            {
                return;
            }

            int node = VehicleDataFindEmptySeat(thisobj, vehicle, player);

            if (node == -1)
            {
                return;
            }
            vehicle.mountObject(player, node, new TransformF(true));
            player["mVehicle"] = vehicle;
        }
Example #10
0
        public void ServerCmdcarUnmountObj(coGameConnection client, coPlayer obj)
        {
            obj.unmount();
            obj.setControlObject(obj);

            TransformF ejectpos = obj.getTransform();

            ejectpos += new TransformF(0, 0, 5);
            obj.setTransform(ejectpos);

            coVehicle mvehicle = obj["mVehicle"];

            Point3F ejectvel = mvehicle.getVelocity();

            ejectvel += new Point3F(0, 0, 10);

            ejectvel = ejectvel.vectorScale(((coSimDataBlock)(obj.getDataBlock()))["mass"].AsFloat());

            obj.applyImpulse(ejectpos.MPosition, ejectvel);
        }
Example #11
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());
            }
        }
Example #12
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);
            }
        }
Example #13
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"));
            }
        }
Example #14
0
 public void VehicleDataIsMountable(coVehicleData thisobj, coVehicle obj, bool val)
 {
     obj["mountable"] = val.AsString();
 }