public StoredCustomModel(string name, bool overrideFileName = false)
            {
                this.modelName = ModelInfo.GetRawModel(name);
                this.scale     = ModelInfo.GetRawScale(name);

                var split = this.modelName.Split(new char[] { '(' }, StringSplitOptions.RemoveEmptyEntries);

                // "player+named", "aaa,bbbb)"
                if (split.Length == 2 && split[1].EndsWith(")"))
                {
                    if (overrideFileName || this.Exists())
                    {
                        // if "player+ (sit)" was a file, use that as override
                        this.fileName = this.modelName;
                    }
                    this.modelName = split[0];

                    // remove ")"
                    var attrs = split[1].Substring(0, split[1].Length - 1);
                    foreach (var attr in attrs.SplitComma())
                    {
                        if (attr.Trim() == "")
                        {
                            continue;
                        }
                        this.modifiers.Add(attr);
                    }
                }
            }
Esempio n. 2
0
        static void SendModelScales(Player pl, byte id, Entity entity)
        {
            if (!pl.Supports(CpeExt.EntityProperty))
            {
                return;
            }

            float scale = ModelInfo.GetRawScale(entity.Model);
            float max   = ModelInfo.MaxScale(entity);

            SendModelScale(pl, id, EntityProp.ScaleX, entity.ScaleX * scale, max);
            SendModelScale(pl, id, EntityProp.ScaleY, entity.ScaleY * scale, max);
            SendModelScale(pl, id, EntityProp.ScaleZ, entity.ScaleZ * scale, max);
        }
Esempio n. 3
0
        public static void HitPlayer(PlayerBot bot, Player p, Orientation rot)
        {
            // Send player backwards if hit
            // Code "borrowed" from PvP plugin

            int srcHeight = ModelInfo.CalcEyeHeight(bot);
            int dstHeight = ModelInfo.CalcEyeHeight(p);
            int dx2 = bot.Pos.X - p.Pos.X, dy2 = (bot.Pos.Y + srcHeight) - (p.Pos.Y + dstHeight), dz2 = bot.Pos.Z - p.Pos.Z;

            Vec3F32 dir2 = new Vec3F32(dx2, dy2, dz2);

            if (dir2.Length > 0)
            {
                dir2 = Vec3F32.Normalise(dir2);
            }

            float mult    = 1 / ModelInfo.GetRawScale(p.Model);
            float plScale = ModelInfo.GetRawScale(p.Model);

            float VelocityY = 1.0117f * mult;

            if (dir2.Length <= 0)
            {
                VelocityY = 0;
            }

            if (p.Supports(CpeExt.VelocityControl))
            {
                // Intensity of force is in part determined by model scale
                p.Send(Packet.VelocityControl((-dir2.X * mult) * 0.57f, VelocityY, (-dir2.Z * mult) * 0.57f, 0, 1, 0));
            }

            // If we are very close to a player, switch from trying to look
            // at them to just facing the opposite direction to them

            rot.RotY = (byte)(p.Rot.RotY + 128);
            bot.Rot  = rot;
        }