Example #1
0
        public override void Spawn(string world, Types.Vec3f position, Types.Vec3f direction)
        {
            if (isSpawned)
            {
                return;
            }

            if (direction == null)
            {
                direction = new Types.Vec3f(0, 0, 1);
            }
            isSpawned = true;



            Proto.Map       = world;
            proto.Position  = position;
            proto.Direction = direction;

            BitStream stream = Program.server.SendBitStream;

            stream.Reset();

            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.NPCSpawnMessage);
            stream.Write(proto.ID);
            stream.Write(Proto.Map);

            stream.Write(proto.Position);
            stream.Write(proto.Direction);

            using (RakNetGUID guid = this.Proto.GUID)
                Program.server.ServerInterface.Send(stream, PacketPriority.HIGH_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, guid, false);
        }
Example #2
0
        internal Text3D(Player aPlayer, World aWorld, float aMaxDistance, ColorRGBA aDefaultColor, long aDefaultBlendTime, Types.Vec3f aPosition, bool aUseCreate)
            : base(0, 0, aPlayer != null, aPlayer != null ? aPlayer.ID : 0, null)
        {
            if (aPosition == null)
            {
                throw new ArgumentException("Parameter Position can not be null!");
            }
            if (aDefaultColor == null)
            {
                throw new ArgumentException("Parameter DefaultColor can not be null!");
            }

            m_Position         = aPosition;
            m_Rows             = new List <Text3DRow>();
            m_Player           = aPlayer;
            m_MaxDistance      = aMaxDistance;
            m_DefaultColor     = aDefaultColor;
            m_DefaultBlendTime = aDefaultBlendTime;
            m_World            = aWorld;

            if (aUseCreate)
            {
                create(-1);
            }
        }
        public override void Spawn(string map, Types.Vec3f position, Types.Vec3f direction)
        {
            this.Map       = map;
            this.Position  = position;
            this.Direction = direction;

            spawned = true;

            if (this.Address != 0)
            {
                return;
            }

            if (this.Map != Player.Hero.Map)
            {
                return;
            }

            Process process = Process.ThisProcess();
            oCItem  item    = oCObjectFactory.GetFactory(process).CreateItem("ITGUC_" + this.ItemInstance.ID);

            item.Amount = this.Amount;


            oCGame.Game(process).World.AddVob(item);
            this.Address = item.Address;
            sWorld.SpawnedVobDict.Add(item.Address, this);

            this.setDirection(Direction);
            this.setPosition(Position);
        }
Example #4
0
 public override void Spawn(string world, Types.Vec3f position, Types.Vec3f direction)
 {
     if (ProtoItem.Container != null)
     {
         throw new Exception("Item can be only spawned if not in a container!");
     }
     base.Spawn(world, position, direction);
 }
Example #5
0
        public void setSpawnInfos(String world, Types.Vec3f position, Types.Vec3f direction)
        {
            if (isSpawned)
            {
                return;
            }

            if (world != null)
            {
                Proto.Map = world;
            }
            if (position != null)
            {
                proto.Position = position;
            }
            if (direction != null)
            {
                proto.Direction = direction;
            }
        }
Example #6
0
        public virtual void setPosition(Vec3f aPosition)
        {
            if (aPosition == null)
            {
                throw new ArgumentNullException("Parameter Pos can not be null");
            }
            this.m_Position = aPosition;

            BitStream stream = Program.server.SendBitStream;

            stream.Reset();
            stream.Write((byte)RakNet.DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
            stream.Write((byte)NetworkID.GuiMessage);
            stream.Write((byte)GuiMessageType.Text3DPosition);

            stream.Write(this.id);
            stream.Write(this.m_Position);

            sendStream(0, stream);
        }
Example #7
0
        public static NPCInst CreateDummyInst(NPCDef npcDef, string name, Types.Vec3f spawnPosition, Random random)
        {
            random = random ?? new Random();

            int guild      = random.Next(0, 2);
            int armorType  = random.Next(0, 4);
            int meleeType  = random.Next(0, 4);
            int rangedType = random.Next(0, 2);

            NPCInst npcInst = null;

            npcInst = new NPCInst(npcDef);
            npcInst.SetObjName(name);
            npcInst.BaseInst.SetNeedsClientGuide(true);

            ItemInst      armor = null, weapon = null, rangeWeapon = null, ammo = null;
            int           ammoAmount;
            ScriptOverlay overlay       = null;
            bool          overlayExists = false;

            armor = new ItemInst(ItemDef.Get <ItemDef>(ArmorCodes[random.Next(0, ArmorCodes.Count)]));

            // melee weapon
            if (random.Next(0, 2) == 0)
            {
                // 1H-weapon
                weapon        = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_1H[random.Next(0, WeaponCodes_1H.Count)]));
                overlayExists = npcInst.ModelDef.TryGetOverlay("1HST2", out overlay);
            }
            else
            {
                // 2H-weapon
                weapon        = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_2H[random.Next(0, WeaponCodes_2H.Count)]));
                overlayExists = npcInst.ModelDef.TryGetOverlay("2HST1", out overlay);
            }

            // ranged weapon
            if (random.Next(0, 2) == 0)
            {
                // bow
                rangeWeapon = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_Bow[random.Next(0, WeaponCodes_Bow.Count)]));
                ammo        = new ItemInst(ItemDef.Get <ItemDef>(AmmoCodes_Bow[random.Next(0, AmmoCodes_Bow.Count)]));
            }
            else
            {
                // crossbow
                rangeWeapon = new ItemInst(ItemDef.Get <ItemDef>(WeaponCodes_Crossbow[random.Next(0, WeaponCodes_Crossbow.Count)]));
                ammo        = new ItemInst(ItemDef.Get <ItemDef>(AmmoCodes_Crossbow[random.Next(0, AmmoCodes_Crossbow.Count)]));
            }

            ammoAmount = random.Next(10, 500 + 1);
            ammo.BaseInst.SetAmount(ammoAmount);

            npcInst.Inventory.AddItem(weapon);
            npcInst.EffectHandler.TryEquipItem(weapon); // 1 = DrawnWeapon

            npcInst.Inventory.AddItem(rangeWeapon);
            npcInst.EffectHandler.TryEquipItem(rangeWeapon);

            npcInst.Inventory.AddItem(ammo);
            npcInst.EffectHandler.TryEquipItem(ammo);

            npcInst.Inventory.AddItem(armor);
            npcInst.EffectHandler.TryEquipItem(armor);

            if (overlayExists)
            {
                npcInst.ModelInst.ApplyOverlay(overlay);
            }

            npcInst.Spawn(WorldSystem.WorldInst.List[0], spawnPosition, Types.Angles.Null);

            return(npcInst);
        }
 public override void setPosition(Types.Vec3f aPosition)
 {
     throw new NotSupportedException("You can not set the Player-Text position!");
 }
Example #9
0
 public Text3D(float aMaxDistance, ColorRGBA aDefaultColor, World aWorld, Types.Vec3f aPosition)
     : this(null, aWorld, aMaxDistance, aDefaultColor, 500, aPosition, true)
 {
 }
Example #10
0
 public void setPosition(Types.Vec3f position)
 {
     m_Position = position;
 }