Inheritance: MonoBehaviour
Example #1
1
    //Method to be re written when serialisation/deserialisation implemented.
    public Game NewGame(Player newPlayer)
    {
        Game game = new Game(newPlayer);

        GameObject mayorSpawn = GameObject.Find("MayorSpawnLocation-Beach");
        GameObject ethanSpawn = GameObject.Find("EthanSpawnLocation-Hut");
        GameObject jennaSpawn = GameObject.Find("JennaSpawnPoint-forest");
        GameObject fisherSpawn = GameObject.Find("FisherSpawnPoint-headland");

        Npc mayor = new Npc("Mayor", "Mayor", mayorSpawn.transform.position, 1f, true);
        Npc ethan = new Npc("Ethan", "Ethan", ethanSpawn.transform.position, 0.2f, true);
        Npc jenna = new Npc("Jenna", "npc1", jennaSpawn.transform.position,0.3f, true);
        Npc fisher = new Npc("Fisher", "fisher", fisherSpawn.transform.position,0f, false);

        game.AddNpc(mayor);
        game.AddNpc(ethan);
        game.AddNpc(jenna);
        game.AddNpc(fisher);

        RecyclePoint beachPoint = new RecyclePoint("BeachRecyclePoint", 50);
        game.RecyclePoints.Add(beachPoint);

        game.CheckPoints.Add ("SpokenToMayorFirst");
        game.CheckPoints.Add ("SpokenToEthan");
        game.CheckPoints.Add ("FirstEthanMeetingPositive");
        game.CheckPoints.Add ("MayorLeaveBeach");
        game.CheckPoints.Add ("BeachRecyclePointFull");
        game.CheckPoints.Add ("StartSortingMiniGame");

        game.IsNewGame = false;
        return game;
    }
Example #2
0
        public static void load()
        {
            if (!File.Exists(misc.getServerPath() + @"\data\npcs.xml"))
            {
                misc.WriteError(@"Missing data\npcs.xml");
                return;
            }
            try {
                //Deserialize text file to a new object.
                StreamReader objStreamReader = new StreamReader(misc.getServerPath() + @"\data\npcs.xml");
                XmlSerializer serializer = new XmlSerializer(typeof(List<NpcSpawn>));
                List<NpcSpawn> spawns = (List<NpcSpawn>)serializer.Deserialize(objStreamReader);

                foreach (NpcSpawn ns in spawns)
                {
                    Npc n = new Npc(ns.id, ns.location);
                    n.setMinimumCoords(ns.minimumCoords);
                    n.setMaximumCoords(ns.maximumCoords);
                    n.setWalkType(ns.walkType);
                    n.setFaceDirection(ns.faceDirection);
                    Server.getNpcList().Add(n);
                }
            }
            catch (Exception e)
            {
                misc.WriteError((e.InnerException == null ? e.ToString() : e.InnerException.ToString()));
            }
            Console.WriteLine("Spawned " + Server.getNpcList().Count + " npcs.");
        }
Example #3
0
 private static bool canThieveNpc(Player p, Npc npc, int index)
 {
     if (p == null || npc == null || npc.isDead() || npc.isHidden() || npc.isDestroyed() || p.isDead() || p.isDestroyed()) {
         return false;
     }
     if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
         return false;
     }
     if (p.getSkills().getGreaterLevel(Skills.SKILL.THIEVING) < NPC_LVL[index]) {
         p.getPackets().sendMessage("You need a Thieving level of " + NPC_LVL[index] + " to rob this Npc.");
         p.setFaceLocation(npc.getLocation());
         return false;
     }
     if (p.getInventory().findFreeSlot() == -1) {
         p.getPackets().sendMessage("You need a free inventory space for any potential loot.");
         return false;
     }
     if (p.getTemporaryAttribute("stunned") != null) {
         return false;
     }
     if (p.getTemporaryAttribute("lastPickPocket") != null) {
         if (Environment.TickCount - (int)p.getTemporaryAttribute("lastPickPocket") < 1500) {
             return false;
         }
     }
     return true;
 }
Example #4
0
 public static bool npcAttack(Npc npc, Entity target)
 {
     if (npcHasAttack(npc)) {
         doNpcAttack(npc, target);
         return true;
     }
     return false;
 }
Example #5
0
 public Npc Copy()
 {
     Npc copy = new Npc (name, spriteName, CurrentStartPosition, MovementBoxSize, canMove);
     if (CurrentDialogueBlock != null) {
         copy.CurrentDialogueBlock = CurrentDialogueBlock.Copy ();
     }
     return copy;
 }
Example #6
0
        public Dialog(Player.Player player, Npc.Npc target, int special, int dialogId, int stage = 1)
        {
            Player = player;
            Target = target;
            Special = special;
            DialogId = dialogId;
            Stage = stage;

            Buttons = new List<DialogButton>();
            Rewards = new List<QuestReward>();
        }
 public AppearanceUpdateFlags(Npc npc)
 {
     this.npc = npc;
     animationUpdateRequired = false;
     entityFocusUpdateRequired = false;
     forceTextUpdateRequired = false;
     graphicsUpdateRequired = false;
     hitUpdateRequired = false;
     hit2UpdateRequired = false;
     faceLocationUpdateRequired = false;
 }
Example #8
0
 public static void GiveItem( Npc npc, ActorPC receiver, int itemID )
 {
     Item nItem = new Item( itemID );
     nItem.creatorName = npc.Name;
     if( nItem == null )
     {
         SagaLib.Logger.ShowWarning( "Script error: cannot create item with ID " + itemID, null );
         return;
     }
     npc.Map.AddItemToActor(receiver, nItem, ITEM_UPDATE_REASON.NPC_GAVE);
 }
Example #9
0
 public static void interactWithAliMorissaae(Player p, Npc n)
 {
     p.setEntityFocus(n.getClientIndex());
     AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
     interactWithAliMorissaaeAreaEvent.setAction(() => {
         n.setFaceLocation(p.getLocation());
         p.setFaceLocation(n.getLocation());
         p.setEntityFocus(65535);
         showAliDialogue(p, 205);
     });
     Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent);
 }
Example #10
0
        public void Should_Translate_Add_Expression()
        {
            var script = "função soma() retorne 2 + 2 fim";

            var bytecode = new Npc().Compilar(script);

            var dm = new ILTranslator(bytecode).Translate();

            var result = dm.Invoke(null, null);

            Assert.AreEqual(4, result);
        }
Example #11
0
 public static bool wantToThieveNpc(Player p, Npc npc)
 {
     for (int i = 0; i < NPCS.Length; i++) {
         for (int j = 0; j < NPCS[i].Length; j++)
         {
             if (npc.getId() == NPCS[i][j]) {
                 thieveNpc(p, npc , i);
                 return true;
             }
         }
     }
     return false;
 }
Example #12
0
        protected override EBTState OnEnter()
        {
            Debuger.Log("enter move to player");
            Ilife owner = m_Database.GetData<Ilife>(EDataBaseKey.Owner);
            if (null == owner)
            {
                return EBTState.False;
            }

            m_TargetNpc = (Npc)(owner);
            m_TargetNpc.MoveTo(PlayerManager.Instance.GetPlayerInstance().GetFollowPoint(m_iFollowPintId).transform.position);
            m_fDeltaTime = 0.0f;
            return EBTState.Running;
        }
Example #13
0
	/// <summary>
	/// NPC头顶文字
	/// </summary>
	/// <param name="npc"></param>
	private static void CreateHeadTip(Npc npc)
	{
		var headTip = (GameObject.Instantiate(Resources.Load("Prefabs/Gui/HeadTip")) as GameObject).GetComponent<UILabel>();
#if UNITY_EDITOR
		headTip.name = npc.name;
#endif
		headTip.text = npc.TableInfo.name;
		headTip.hideIfOffScreen = true;
		headTip.SetAnchor(npc.gameObject);
		headTip.bottomAnchor.absolute = 120;
		headTip.topAnchor.absolute = headTip.bottomAnchor.absolute + 30;

		var recycle = npc.gameObject.AddComponent<OnDestroyAction>();
		recycle.Action = () => { try { NGUITools.Destroy(headTip.gameObject); } catch { } };
	}
Example #14
0
        public static bool wantToFish(Player p, Npc npc, bool secondOption)
        {
            for (int i = 0; i < SPOT_IDS.Length; i++) {
                if (npc.getId() == SPOT_IDS[i]){
                    p.setFaceLocation(npc.getLocation());

                    AreaEvent startFishingAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
                    startFishingAreaEvent.setAction(() => {
                        startFishing(p, i, npc, true, secondOption);
                    });
                    Server.registerCoordinateEvent(startFishingAreaEvent);
                    return true;
                }
            }
            return false;
        }
Example #15
0
        public SpawnNpc(Npc npc)
            : base(0x34,29)
        {
            writer.Write(npc.WorldId);
            writer.Write((ushort)npc.NpcId);
            writer.Write((byte)npc.Shape);
            writer.Write(npc.X);
            writer.Write(npc.Y);
            writer.Write(npc.Z);
            writer.Write(npc.DX);
            writer.Write(npc.DY);

            for(int i=0;i<8;i++) {
                writer.Write((byte)0);
            }
        }
Example #16
0
 public static void checkSlayerKill(Player p, Npc npc)
 {
     if (p.getSlayerTask() == null) {
         return;
     }
     SlayerTask task = p.getSlayerTask();
     object[][] data = getMasterData(task.getMasterIndex());
     for (int i = 1; i < data[task.getMonsterIndex()].Length; i++) {
         if (npc.getId() == (int) data[task.getMonsterIndex()][i]) {
             if (npc.getKiller().Equals(p)) {
                 p.getSkills().addXp(Skills.SKILL.SLAYER, npc.getMaxHp());//(double) data[task.getMonsterIndex()][1]);
                 checkIfCompleteTask(p, task);
                 break;
             }
         }
     }
 }
Example #17
0
 public EnemySprite(Npc enemy, Texture2D sprite, 
         Dictionary<AnimationKey, Animation> animation, int eWidth, int eHeight, bool isBoss)
     : base(sprite, animation)
 {
     this.Enemy = enemy;
     this.currentLookingPosition = LookingPosition.LookDown;
     this.battleEngaged = false;
     this.outOfPatrollingArea = false;
     this.AttackingPlayer = false;
     this.Position = new Vector2((float)enemy.Location.X, (float)enemy.Location.Y);
     this.patrollingAreaWidth = enemy.Location.PerimeterWidth;
     this.patrollingAreaHeight = enemy.Location.PerimeterHeight;
     this.enemyView = enemy.Location.FieldOfView;
     this.patrollingArea = new Rectangle((int)Position.X, (int)Position.Y, patrollingAreaWidth, patrollingAreaHeight);
     this.enemyWidth = eWidth;
     this.enemyHeight = eHeight;
     this.IsBoss = isBoss;
 }
Example #18
0
        public static bool interactWithBoatNPC(Player p, Npc n)
        {
            int id = n.getId();
            if (id != 4540 && id != 1304 && id != 2436 && id != 3781 && id != 1361 && id != 4962) {
                return false;
            }
            p.setEntityFocus(n.getClientIndex());
            AreaEvent interactWithBoatNPCAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1);
            interactWithBoatNPCAreaEvent.setAction(() => {
                n.setFaceLocation(p.getLocation());
                p.setFaceLocation(n.getLocation());
                p.setEntityFocus(65535);
                switch(n.getId()) {
                    case 4540: // Home boat
                        showBentleyDialogue(p, 240);
                        break;

                    case 1304: // Canifis sailor
                        showCanifisSailorDialogue(p, 280);
                        break;

                    case 2436: // Waterbirth isle
                        showJarvaldDialogue(p, 300);
                        break;

                    case 3781: // Pest control squire
                        showSquireDialogue(p, 340);
                        break;

                    case 1361: // Warrior guild
                        showArnorDialogue(p, 370);
                        break;

                    case 4962: // fremmenik shore
                        showCaptainBarnabyDialogue(p, 410);
                        break;
                }
            });
            Server.registerCoordinateEvent(interactWithBoatNPCAreaEvent);
            return true;
        }
Example #19
0
        private static void doNpcAttack(Npc npc, Entity target)
        {
            switch(npc.getId()) {
                case DHAROK:
                case AHRIM:
                case TORAG:
                case VERAC:
                case KARIL:
                case GUTHAN:
                    BarrowNPCAttacks.attack(npc, target);
                    break;

                case 6263:
                case 6260:
                case 6265:
                case 6247:
                case 6250:
                case 6252:
                case 6203:
                case 6208:
                case 6206:
                case 6222:
                case 6223:
                case 6225:
                    GodwarsAttacks.attack(npc, target);
                    break;

                case 2734:
                case 2735:
                case 2739:
                case 2740:
                case 2741:
                case 2742:
                case 2743:
                case 2744:
                case 2745:
                    FightCave.fightCaveAttacks(npc, ((Player)target));
                    break;
            }
        }
Example #20
0
        public override void Initialize()
        {
            base.Initialize();

            if (ParentWorld != null)
            {
                Npc npc = new Npc(ParentWorld, this, Difficulty);

                if (Difficulty >= 0)
                {
                    CharacterAppearance.LoadFromFile("../../../../Characters/enemy_npc.xml").GiveAppearanceTo(npc,0f);

                    if (Difficulty != 0)
                        npc.Weapon = new Weapons.Knife(npc, ParentWorld, Color.Red);

                } else
                {
                    CharacterAppearance.LoadFromFile("../../../../Characters/friendly_npc.xml").GiveAppearanceTo(npc, 0f);
                }

                npc.Initialize();
                npc.Color = Color;
            }
        }
Example #21
0
        protected bool checkHitTarget()
        {
            int cannonX = fakeCannonLocation.getX();
            int cannonY = fakeCannonLocation.getY();
            Npc[] npcsToAttack = new Npc[npcsInArea.Count];
            bool hit = false;
            foreach(Npc n in Server.getNpcList()) {
                hit = false;
                Location l = n.getLocation();
                if (n == null || n.isHidden() || n.isDead() || !n.getLocation().withinDistance(fakeCannonLocation, 8)) {
                    continue;
                }
                switch(direction) {
                    case 0: // North
                        hit = l.inArea(cannonX-1, cannonY, cannonX+1, cannonY+8);
                        break;

                    case 1: // North east
                        break;

                    case 2: // East:
                        hit = l.inArea(cannonX, cannonY-1, cannonX+8, cannonY+1);
                        break;

                    case 3: // South east
                        break;

                    case 4: // South
                        hit = l.inArea(cannonX-1, cannonY-8, cannonX+1, cannonY);
                        break;

                    case 5: // South west
                        break;

                    case 6: // West
                        hit = l.inArea(cannonX-8, cannonY-1, cannonX, cannonY+1);
                        break;

                    case 7: // North west
                        break;
                }
                if (hit) {
                    Npc npc = n;
                    p.getPackets().sendProjectile(fakeCannonLocation, n.getLocation(), 30, 53, 50, 38, 38, 40, n);
                    Event doCannonHitEvent = new Event(1000);
                    doCannonHitEvent.setAction(() => {
                        doCannonHitEvent.stop();
                        int damage = misc.random(30);
                        p.getSkills().addXp(Skills.SKILL.RANGE, damage * 2);
                        npc.hit(damage);
                        npc.setLastAnimation(new Animation(npc.getDefenceAnimation()));
                    });
                    Server.registerEvent(doCannonHitEvent);
                    return true;
                }
            }
            return false;
        }
Example #22
0
 void OnTriggerEnter(Collider col)
 {
     Npc guest = col.gameObject.GetComponent<Npc>();
     if (guest != null && mingler == null && SearchingforArea == null)
     {
         float distance = Vector3.Distance(guest.transform.position, transform.position);
         if (distance > 0.5f)
         {
             if (guest.State == states.Afraid)
                 State = states.Afraid;
             else if (guest.State == states.Idle)
             {
                 mingler = guest;
                 guest.mingler = this;
                 guest.State = states.Talking;
                 State = states.Talking;
             }
         } else
         {
             direction = Move[Random.Range(0, Move.Length)];
             Vector3 move = direction + new Vector3(direction.x * Random.Range(1f, 20f), direction.y * Random.Range(1f, 12f), -0.1f);
             bool walkable = (Physics.CheckSphere(move, 0.5f, layermask));
             if (walkable)
             {
                 State = states.Walk;
                 Unit.MoveTo(move);
             }
             else
             {
                 counter = SetCounter;
             }
         }
     }
 }
Example #23
0
 public override void OnNewLeader(Npc npc)
 {
     npc.Leader.Followers--;
     npc.Agent.autoBraking      = true;
     npc.Agent.stoppingDistance = 0.05f + (0.01f * npc.Leader.Followers);
 }
Example #24
0
 public override bool Check(Npc npc)
 {
     return(npc.CurrentAIPlayerTarget != null && Player.Dictionary.ContainsKey(npc.CurrentAIPlayerTarget.GameObject) && npc.CurrentAIPlayerTarget.IsAlive && !Physics.Linecast(npc.NPCPlayer.Position, npc.CurrentAIPlayerTarget.Position, npc.NPCPlayer.ReferenceHub.playerMovementSync.CollidableSurfaces));
 }
    void Update()
    {
        Player player = Utils.ClientLocalPlayer();

        if (!player)
        {
            return;
        }

        // use collider point(s) to also work with big entities
        if (panel.activeSelf &&
            player.target != null && player.target is Npc &&
            Utils.ClosestDistance(player.collider, player.target.collider) <= player.interactionRange)
        {
            Npc npc = (Npc)player.target;

            // welcome text
            welcomeText.text = npc.welcome;

            // trading button
            tradingButton.gameObject.SetActive(npc.saleItems.Length > 0);
            tradingButton.onClick.SetListener(() => {
                npcTradingPanel.SetActive(true);
                inventoryPanel.SetActive(true); // better feedback
                panel.SetActive(false);
            });

            // teleport button
            teleportButton.gameObject.SetActive(npc.teleportTo != null);
            if (npc.teleportTo != null)
            {
                teleportButton.GetComponentInChildren <Text>().text = "Teleport: " + npc.teleportTo.name;
            }
            teleportButton.onClick.SetListener(() => {
                player.CmdNpcTeleport();
            });

            // filter out the quests that are available for the player
            List <ScriptableQuest> questsAvailable = npc.QuestsVisibleFor(player);
            questsButton.gameObject.SetActive(questsAvailable.Count > 0);
            questsButton.onClick.SetListener(() => {
                npcQuestPanel.SetActive(true);
                panel.SetActive(false);
            });

            // guild
            guildButton.gameObject.SetActive(npc.offersGuildManagement);
            guildButton.onClick.SetListener(() => {
                npcGuildPanel.SetActive(true);
                panel.SetActive(false);
            });

            // pet revive
            petReviveButton.gameObject.SetActive(npc.offersPetRevive);
            petReviveButton.onClick.SetListener(() => {
                npcPetRevivePanel.SetActive(true);
                inventoryPanel.SetActive(true); // better feedback
                panel.SetActive(false);
            });
        }
        else
        {
            panel.SetActive(false);  // hide
        }
    }
Example #26
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            // trackers for statically drawn sprites as we move through draw order
            bool            showCraftingMenu = false;
            bool            showStorageMenu  = false;
            ICraftingObject craftObj         = null;
            Storage         invStorage       = null;

            Ship playerShip = gameState.player.playerOnShip;
            List <InventoryItem> invItemsPlayer = gameState.player.inventory;
            List <InventoryItem> invItemsShip   = (gameState.player.playerOnShip == null) ? null : gameState.player.playerOnShip.actionInventory;

            if (gameState.player.onShip)
            {
                invItemsShip = gameState.player.playerOnShip.actionInventory;
            }


            // game menu before everything
            if (startingMenu.showMenu)
            {
                startingMenu.DrawInventory(spriteBatchStatic);
                return;
            }

            // draw the interior view if in interior
            if (gameState.player.playerInInterior != null)
            {
                gameState.player.playerInInterior.interiorObjects.Add(gameState.player);

                GraphicsDevice.SetRenderTarget(lightsTarget);
                GraphicsDevice.Clear(Color.Black);
                DrawUtility.DrawSpotLighting(spriteBatchView, this.camera, lightsTarget, gameState.player.playerInInterior.interiorObjects.ToList());

                gameState.player.playerInInterior.Draw(spriteBatchView, this.camera, interiorScene);

                // lighting shader - for ambient day/night light and lanterns
                GraphicsDevice.SetRenderTarget(null);
                GraphicsDevice.Clear(Color.White);
                dayLight.Draw(spriteBatchStatic, interiorScene, lightsTarget);

                showCraftingMenu = gameState.player.playerInInterior.showCraftingMenu;
                showStorageMenu  = gameState.player.playerInInterior.showStorageMenu;
                craftObj         = gameState.player.playerInInterior.craftObj;
                invStorage       = gameState.player.playerInInterior.invStorage;
            }
            // not in interior so draw the game scene
            else
            {
                // setup lightTarget for spot lights
                GraphicsDevice.SetRenderTarget(lightsTarget);
                GraphicsDevice.Clear(Color.Black);
                DrawUtility.DrawSpotLighting(spriteBatchView, this.camera, lightsTarget, DrawOrder);

                // draw map
                map.DrawMap(spriteBatchView, spriteBatchStatic, worldScene);

                // draw treasure locations if any
                spriteBatchView.Begin(this.camera);
                foreach (var map in BoundingBoxLocations.treasureLocationsList)
                {
                    spriteBatchView.Draw(treasureXMark, map.digTileLoc, Color.White);
                }
                spriteBatchView.End();

                // draw shadows and wakes
                foreach (var sprite in DrawOrder)
                {
                    if (sprite is IShadowCaster)
                    {
                        sprite.DrawShadow(spriteBatchView, camera, WeatherState.sunAngleX, WeatherState.shadowTransparency);
                        if (sprite.GetType().BaseType == typeof(Gusto.Models.Animated.Ship))
                        {
                            Ship ship = (Ship)sprite;
                            ship.shipSail.DrawShadow(spriteBatchView, this.camera, WeatherState.sunAngleX, WeatherState.shadowTransparency);
                        }
                    }

                    if (sprite is IWakes)
                    {
                        IWakes             waker = (IWakes)sprite;
                        WakeParticleEngine wpe   = waker.GetWakeEngine();
                        wpe.Draw(spriteBatchView, camera);
                    }
                }

                List <Sprite> fliers = new List <Sprite>(); // draw any flyers on top of everything
                // sort sprites by y cord asc and draw
                DrawOrder.Sort((a, b) => a.GetBoundingBox().Bottom.CompareTo(b.GetBoundingBox().Bottom));
                int i = 0;
                foreach (var sprite in DrawOrder)
                {
                    if (sprite is IVulnerable)
                    {
                        IVulnerable v = (IVulnerable)sprite;
                        v.DrawHealthBar(spriteBatchView, camera);
                    }

                    if (sprite is IInventoryItem)
                    {
                        InventoryItem item = (InventoryItem)sprite;
                        if (!item.inInventory)
                        {
                            item.DrawPickUp(spriteBatchView, camera);
                        }
                    }

                    if (sprite is ICraftingObject)
                    {
                        ICraftingObject tcraftObj = (ICraftingObject)sprite;
                        tcraftObj.DrawCanCraft(spriteBatchView, camera);
                        if (tcraftObj.GetShowMenu())
                        {
                            showCraftingMenu = true;
                            craftObj         = tcraftObj;
                        }
                    }

                    if (sprite is IPlaceable)
                    {
                        IPlaceable placeObj = (IPlaceable)sprite;
                        placeObj.DrawCanPickUp(spriteBatchView, camera);
                    }

                    if (sprite is IStructure)
                    {
                        IStructure structure = (IStructure)sprite;
                        structure.DrawNearInterior(spriteBatchView, camera);
                    }

                    if (sprite is IStorage)
                    {
                        Storage storage = (Storage)sprite;
                        storage.DrawOpenStorage(spriteBatchView, camera);
                        if (storage.storageOpen)
                        {
                            showStorageMenu = true;
                            invStorage      = storage;
                        }
                    }

                    if (sprite.GetType().BaseType == typeof(Gusto.Models.Animated.Ship))
                    {
                        Ship ship = (Ship)sprite;

                        if (ship.sinking)
                        {
                            ship.DrawSinking(spriteBatchView, this.camera);
                            ship.shipSail.DrawSinking(spriteBatchView, this.camera);
                        }
                        else
                        {
                            // Draw a ship before its sail and mount
                            ship.Draw(spriteBatchView, this.camera);
                            if (ship.mountedOnShip != null)
                            {
                                foreach (var shot in ship.mountedOnShip.Shots)
                                {
                                    shot.Draw(spriteBatchView, this.camera);
                                }
                                if (ship.mountedOnShip.aiming)
                                {
                                    ship.mountedOnShip.Draw(spriteBatchView, this.camera);
                                    if (ship.teamType == TeamType.Player)
                                    {
                                        ship.mountedOnShip.DrawAimLine(spriteBatchView, this.camera);
                                    }
                                }
                            }
                            ship.shipSail.Draw(spriteBatchView, this.camera);
                        }
                        continue;
                    }

                    else if (sprite.GetType() == typeof(Gusto.AnimatedSprite.PiratePlayer))
                    {
                        DrawUtility.DrawPlayer(spriteBatchView, this.camera, gameState.player);
                        continue;
                    }

                    else if (sprite.GetType().BaseType == typeof(Gusto.Models.Animated.Npc))
                    {
                        Npc npc = (Npc)sprite;

                        // flying drawn after everything else
                        if (npc.flying)
                        {
                            fliers.Add(npc);
                            continue;
                        }

                        if (npc.swimming && !npc.onShip)
                        {
                            npc.DrawSwimming(spriteBatchView, this.camera);
                        }
                        else if (!npc.onShip)
                        {
                            npc.Draw(spriteBatchView, this.camera);
                        }
                        if (npc.dying)
                        {
                            npc.DrawDying(spriteBatchView, this.camera);
                        }
                        continue;
                    }

                    else if (sprite.GetType() == typeof(Gusto.AnimatedSprite.BaseTower))
                    {
                        Tower tower = (Tower)sprite;
                        sprite.Draw(spriteBatchView, this.camera);
                        // draw any shots this tower has in motion
                        foreach (var shot in tower.Shots)
                        {
                            shot.Draw(spriteBatchView, this.camera);
                        }
                        continue;
                    }

                    if (sprite.GetType() == typeof(Gusto.Models.Menus.Inventory) || sprite.GetType() == typeof(Gusto.Models.Menus.CraftingMenu))
                    {
                        continue; // we handle this after everthing else
                    }
                    sprite.Draw(spriteBatchView, this.camera);
                }

                // draw fliers
                foreach (var flier in fliers)
                {
                    flier.Draw(spriteBatchView, this.camera);
                }

                // draw weather
                weather.DrawWeather(spriteBatchStatic);

                // lighting shader - for ambient day/night light and lanterns
                GraphicsDevice.SetRenderTarget(null);
                GraphicsDevice.Clear(Color.White);
                dayLight.Draw(spriteBatchStatic, worldScene, lightsTarget);
            }

            // lightning is drawn after ambient light
            if (WeatherState.lightning)
            {
                weather.DrawLightning(spriteBatchStatic);
            }

            // draw static and menu sprites
            windArrows.Draw(spriteBatchStatic, null);

            if (gameState.player.onShip)
            {
                playerShip.DrawAnchorMeter(spriteBatchStatic, new Vector2(1660, 30), anchorIcon);
                playerShip.DrawRepairHammer(spriteBatchStatic, new Vector2(1600, 30), repairIcon);

                if (playerShip.msBoarding > 0)
                {
                    playerShip.DrawBeingBoarded(spriteBatchStatic, new Vector2(1540, 30), boardingIcon);
                }

                if (gameState.player.playerInInterior != null)
                {
                    invItemsShip = null;
                }
            }
            else
            {
                invItemsShip = null;
            }

            if (gameState.player.showInventory)
            {
                inventoryMenu.Draw(spriteBatchStatic, null);
                inventoryMenu.DrawInventory(spriteBatchStatic, invItemsPlayer, invItemsShip, null);
            }
            else if (showCraftingMenu)
            {
                craftingMenu.Draw(spriteBatchStatic, null);
                craftingMenu.DrawInventory(spriteBatchStatic, invItemsPlayer, craftObj);
            }
            else if (showStorageMenu)
            {
                inventoryMenu.Draw(spriteBatchStatic, null);
                inventoryMenu.DrawInventory(spriteBatchStatic, invItemsPlayer, invItemsShip, invStorage);
            }

            // fps
            var deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            _frameCounter.Update(deltaTime);
            var fps = string.Format("FPS: {0}", _frameCounter.AverageFramesPerSecond);

            spriteBatchStatic.Begin();
            spriteBatchStatic.DrawString(font, fps, new Vector2(10, 10), Color.Green);
            spriteBatchStatic.End();
            base.Draw(gameTime);
        }
Example #27
0
 public NpcDofusTalkDialog(Character character, Npc npc)
     : base(character, npc)
 {
     CurrentMessage = NpcDofus.Message;
 }
Example #28
0
 public async Task <IEnumerable <ItemGenerationConfig> > RetrieveItemGenerationConfigForNpc(Npc npc)
 {
     return(await dbConnection.QueryAsync <ItemGenerationConfig>(@"
         SELECT * FROM itemGenerationConfigs WHERE npcID = @npc",
                                                                 new { npc = (int)npc }));
 }
    void Update()
    {
        Player player = Utils.ClientLocalPlayer();

        if (!player)
        {
            return;
        }

        // npc quest
        // use collider point(s) to also work with big entities
        if (player.target != null && player.target is Npc &&
            Utils.ClosestDistance(player.collider, player.target.collider) <= player.interactionRange)
        {
            Npc npc = (Npc)player.target;

            // instantiate/destroy enough slots
            List <ScriptableQuest> questsAvailable = npc.QuestsVisibleFor(player);
            UIUtils.BalancePrefabs(slotPrefab.gameObject, questsAvailable.Count, content);

            // refresh all
            for (int i = 0; i < questsAvailable.Count; ++i)
            {
                UINpcQuestSlot slot = content.GetChild(i).GetComponent <UINpcQuestSlot>();

                // find quest index in original npc quest list (unfiltered)
                int npcIndex = Array.FindIndex(npc.quests, q => q.name == questsAvailable[i].name);

                // find quest index in player quest list
                int questIndex = player.GetQuestIndexByName(npc.quests[npcIndex].name);
                if (questIndex != -1)
                {
                    // running quest: shows description with current progress
                    // instead of static one
                    Quest          quest    = player.quests[questIndex];
                    ScriptableItem reward   = npc.quests[npcIndex].rewardItem;
                    int            gathered = quest.gatherItem != null?player.InventoryCount(new Item(quest.gatherItem)) : 0;

                    bool hasSpace = reward == null || player.InventoryCanAdd(new Item(reward), 1);

                    // description + not enough space warning (if needed)
                    slot.descriptionText.text = quest.ToolTip(gathered);
                    if (!hasSpace)
                    {
                        slot.descriptionText.text += "\n<color=red>Not enough inventory space!</color>";
                    }

                    slot.actionButton.interactable = player.CanCompleteQuest(quest.name);
                    slot.actionButton.GetComponentInChildren <Text>().text = "Complete";
                    slot.actionButton.onClick.SetListener(() => {
                        player.CmdCompleteQuest(npcIndex);
                        panel.SetActive(false);
                    });
                }
                else
                {
                    // new quest
                    slot.descriptionText.text      = new Quest(npc.quests[npcIndex]).ToolTip();
                    slot.actionButton.interactable = true;
                    slot.actionButton.GetComponentInChildren <Text>().text = "Accept";
                    slot.actionButton.onClick.SetListener(() => {
                        player.CmdAcceptQuest(npcIndex);
                    });
                }
            }
        }
        else
        {
            panel.SetActive(false);  // hide
        }
    }
Example #30
0
        public override void Parse(L2PlayerData data)
        {
            reader.ReadInt();             //writeD(_type);
            int objId = reader.ReadInt(); //writeD(obj_id);
            Npc npc   = data.Npcs.ContainsKey(objId) ? data.Npcs[objId] : new Npc();

            if (!data.Npcs.ContainsKey(objId))
            {
                data.Npcs.Add(objId, npc);
            }

            npc.ObjectId = objId;
            npc.UnitId   = reader.ReadInt() - 1000000;         //writeD(npc_id + 1000000);
            reader.ReadInt();                                  //writeD(0); // 1=attackable
            npc.X = reader.ReadInt();                          //writeD(_loc.x);
            npc.Y = reader.ReadInt();                          //writeD(_loc.y);
            npc.Z = reader.ReadInt();                          //writeD(_loc.z);
            reader.ReadInt();                                  //writeD(_loc.h);
            reader.ReadInt();                                  //writeD(0);
            reader.ReadInt();                                  //writeD(MAtkSpd);
            reader.ReadInt();                                  //writeD(PAtkSpd);
            npc.RunningSpeed = reader.ReadInt();               //writeD(_runSpd);
            reader.ReadInt();                                  //writeD(_walkSpd);
            reader.ReadInt();                                  //writeD(_swimRunSpd);
            reader.ReadInt();                                  //writeD(_swimWalkSpd);
            reader.ReadInt();                                  //writeD(0); // flRunSpeed
            reader.ReadInt();                                  //writeD(0); // flWalkSpeed
            reader.ReadInt();                                  //writeD(_flyRunSpd);
            reader.ReadInt();                                  //writeD(_flyWalkSpd);
            npc.MovementSpeedMultiplier = reader.ReadDouble(); //writeF(1/*_cha.getProperMultiplier()*/);
            reader.ReadDouble();                               //writeF(1/*_cha.getAttackSpeedMultiplier()*/);
            reader.ReadDouble();                               //writeF(col_redius);
            reader.ReadDouble();                               //writeF(col_height);
            reader.ReadInt();                                  //writeD(0); // right hand weapon
            reader.ReadInt();                                  //writeD(0);
            reader.ReadInt();                                  //writeD(0); // left hand weapon
            reader.ReadByte();                                 //writeC(1); // name above char 1=true ... ??
            reader.ReadByte();                                 //writeC(runing); // running=1
            reader.ReadByte();                                 //writeC(incombat); // attacking 1=true
            npc.IsDead = reader.ReadByte() == 1;               //writeC(dead); // dead 1=true
            reader.ReadByte();                                 //writeC(_showSpawnAnimation); // invisible ?? 0=false  1=true   2=summoned (only works if model has a summon animation)
            //reader.ReadInt();//writeD(-1);
            npc.Name = reader.ReadString();                    //writeS(_name);
            //reader.ReadInt();//writeD(-1);
            npc.Title = reader.ReadString();                   //writeS(title);
            reader.ReadInt();                                  //writeD(1);
            reader.ReadInt();                                  //writeD(pvp_flag); //0=white, 1=purple, 2=purpleblink, if its greater then karma = purple
            reader.ReadInt();                                  //writeD(karma); // hmm karma ??
            reader.ReadInt();                                  //writeD(curFed); // how fed it is
            reader.ReadInt();                                  //writeD(maxFed); //max fed it can be
            npc.Health    = reader.ReadInt();                  //writeD(curHp); //current hp
            npc.MaxHealth = reader.ReadInt();                  //writeD(maxHp); // max hp
            npc.Mana      = reader.ReadInt();                  //writeD(curMp); //current mp
            npc.MaxMana   = reader.ReadInt();                  //writeD(maxMp); //max mp
            reader.ReadInt();                                  //writeD(_sp); //sp
            npc.Level = reader.ReadInt();                      //writeD(level);// lvl
            reader.ReadLong();                                 //writeQ(exp);
            reader.ReadLong();                                 //writeQ(exp_this_lvl); // 0%  absolute value
            reader.ReadLong();                                 //writeQ(exp_next_lvl); // 100% absoulte value
            reader.ReadInt();                                  //writeD(curLoad); //weight
            reader.ReadInt();                                  //writeD(maxLoad); //max weight it can carry
            reader.ReadInt();                                  //writeD(PAtk);//patk
            reader.ReadInt();                                  //writeD(PDef);//pdef
            reader.ReadInt();                                  //writeD(MAtk);//matk
            reader.ReadInt();                                  //writeD(MDef);//mdef
            reader.ReadInt();                                  //writeD(Accuracy);//accuracy
            reader.ReadInt();                                  //writeD(Evasion);//evasion
            reader.ReadInt();                                  //writeD(Crit);//critical
            reader.ReadInt();                                  //writeD(_runSpd);//speed
            reader.ReadInt();                                  //writeD(PAtkSpd);//atkspeed
            reader.ReadInt();                                  //writeD(MAtkSpd);//casting speed
            reader.ReadInt();                                  //writeD(_abnormalEffect); //c2  abnormal visual effect... bleed=1; poison=2; bleed?=4;
            reader.ReadShort();                                //writeH(rideable);
            reader.ReadByte();                                 //writeC(0); // c2
            reader.ReadShort();                                //writeH(0); // ??
            reader.ReadByte();                                 //writeC(_team.ordinal()); // team aura (1 = blue, 2 = red)
            reader.ReadInt();                                  //writeD(ss);
            reader.ReadInt();                                  //writeD(sps);
            //reader.ReadInt();//writeD(type);
            //reader.ReadInt();//writeD(_abnormalEffect2);
            data.MainHero.PlayerSummons.Clear();
            data.MainHero.PlayerSummons.Add(npc);
        }
Example #31
0
 public async Task <NpcConfig> RetrieveNpcDetailCfg(Npc npc)
 {
     return((await dbConnection.QueryAsync <NpcConfig>(@"SELECT * FROM npcConfigs WHERE npcid = @id",
                                                       new { id = npc })).FirstOrDefault());
 }
    /// <summary>
    /// 创建关卡Npc;
    /// </summary>
    /// <returns></returns>
    public void CreateStageNpc(StageData stage)
    {
        if (stage == null)
        {
            return;
        }

        NpcData npcData = DataManager.s_NpcDataManager.GetData(stage.NpcID);

        if (npcData == null)
        {
            return;
        }

        Npc npc = new Npc(stage.NpcID);

        Quaternion rotate = Quaternion.Euler(new Vector3(0, stage.Orient * Mathf.Rad2Deg, 0));
        GameObject prefab = ResourcesManager.Instance.LoadUnitObject(npcData.Model, UNIT_TYPE.NPC);
        GameObject npcobj = GameObject.Instantiate(prefab) as GameObject;

        npcobj.transform.position = stage.Position;
        npcobj.transform.rotation = rotate;

        UnityEngine.AI.NavMeshAgent agent = npcobj.AddComponent <UnityEngine.AI.NavMeshAgent>();
        agent.speed             = 0;
        agent.acceleration      = 0;
        agent.angularSpeed      = 0;
        agent.avoidancePriority = (int)NavmeshPriority.NPC;
        agent.height            = npcData.Height;
        agent.radius            = npcData.Radius;
        agent.stoppingDistance  = agent.radius;

        /*NavMeshObstacle obstacle = npcobj.AddComponent<NavMeshObstacle>();
         * obstacle.height = npcData.Height;
         * obstacle.radius = npcData.Radius;
         * obstacle.carving = true;*/

        CapsuleCollider collider = npcobj.AddComponent <CapsuleCollider>();

        collider.height = npcData.Height;
        collider.radius = npcData.Radius;
        collider.center = Vector3.up * (Mathf.Max(collider.height / 2.0f, collider.radius) + 0.03f);

        npcobj.SetLayerRecursively(LayerMask.NameToLayer("AttackNpc"));

        if (stage.NpcType == NpcTypes.Battle)
        {
            NpcController controller = npcobj.AddComponent <NpcController>();
            controller.m_Npc          = npc;
            controller.m_CurStageData = stage;
            m_StageNpcControllerDic.Add(stage.ID, controller);
        }
        else if (stage.NpcType == NpcTypes.TreasureBox)
        {
            TreasureBoxController controller = npcobj.AddComponent <TreasureBoxController>();
            controller.m_Npc          = npc;
            controller.m_CurStageData = stage;
            m_StageNpcControllerDic.Add(stage.ID, controller);
        }
        else if (stage.NpcType == NpcTypes.Stone || stage.NpcType == NpcTypes.Crystal ||
                 stage.NpcType == NpcTypes.Wood)
        {
            DungeonCollectController controller = npcobj.AddComponent <DungeonCollectController>();
            controller.m_Npc          = npc;
            controller.m_CurStageData = stage;
            m_StageNpcControllerDic.Add(stage.ID, controller);
        }
    }
Example #33
0
        public void AddButtonsToDialog(Player player, Npc npc, List <DialogButton> buttons)
        {
            foreach (var data in player.Quests)
            {
                //Reward
                if (npc.NpcTemplate.FullId == Quests[data.Key].TryGetRewardNpc(player))
                {
                    DialogIcon icon = DialogIcon.CenteredGray;

                    switch (Data.Data.Quests[data.Key].Type)
                    {
                    case QuestType.Mission:
                        icon = DialogIcon.MissionQuestReward;
                        break;

                    case QuestType.Normal:
                        icon = DialogIcon.NormalQuestReward;
                        break;

                    case QuestType.Guild:
                        icon = DialogIcon.GuildQuestReward;
                        break;
                    }

                    buttons.Add(new DialogButton(icon, Data.Data.Quests[data.Key].QuestTitle));
                }
                else
                {
                    //Talk
                    QStepDefault step = Quests[data.Key].GetNowStep(player);

                    if (step == null)
                    {
                        continue;
                    }

                    List <int> villagers = step.GetParticipantVillagers(player);

                    if (villagers.Count > 0 && npc.NpcTemplate.FullId == villagers[0])
                    {
                        DialogIcon icon = DialogIcon.CenteredGray;

                        switch (Data.Data.Quests[data.Key].Type)
                        {
                        case QuestType.Mission:
                            icon = DialogIcon.MissionQuestProgress;
                            break;

                        case QuestType.Normal:
                            icon = DialogIcon.NormalQuestProgress;
                            break;

                        case QuestType.Guild:
                            icon = DialogIcon.GuildQuestProgress;
                            break;
                        }

                        buttons.Add(new DialogButton(icon, Data.Data.Quests[data.Key].QuestTitle));
                    }
                }
            }

            //Start
            if (NpcStartQuests.ContainsKey(npc.NpcTemplate.FullId))
            {
                for (int i = 0; i < NpcStartQuests[npc.NpcTemplate.FullId].Count; i++)
                {
                    Quest quest = NpcStartQuests[npc.NpcTemplate.FullId][i];

                    if (player.Quests.ContainsKey(quest.QuestId))
                    {
                        continue;
                    }

                    if (!quest.NeedClasses.Contains(player.PlayerData.Class))
                    {
                        continue;
                    }

                    if (quest.NeedLevel > player.Level)
                    {
                        continue;
                    }

                    DialogIcon icon = DialogIcon.CenteredGray;

                    switch (quest.Type)
                    {
                    case QuestType.Mission:
                        icon = DialogIcon.MissionQuestStart;
                        break;

                    case QuestType.Normal:
                        icon = DialogIcon.NormalQuestStart;
                        break;

                    case QuestType.Guild:
                        icon = DialogIcon.GuildQuestStart;
                        break;
                    }

                    buttons.Add(new DialogButton(icon, quest.QuestTitle));
                }
            }
        }
Example #34
0
        public void ShowIcon(Player player, Npc npc, bool force = false)
        {
            if (!npc.NpcTemplate.IsVillager)
            {
                return;
            }

            QuestType       questType = QuestType.Guild;
            QuestStatusIcon icon      = QuestStatusIcon.None;

            //Rewards
            {
                bool isReward = false;

                foreach (var data in player.Quests)
                {
                    if (npc.NpcTemplate.FullId == Quests[data.Key].TryGetRewardNpc(player))
                    {
                        if (Data.Data.Quests[data.Key].Type < questType)
                        {
                            questType = Data.Data.Quests[data.Key].Type;
                            isReward  = true;

                            if (questType == 0)
                            {
                                break;
                            }
                        }
                    }
                }

                if (isReward)
                {
                    switch (questType)
                    {
                    case QuestType.Mission:
                        icon = QuestStatusIcon.RewardMissionQuest;
                        break;

                    case QuestType.Normal:
                        icon = QuestStatusIcon.RewardNormalQuest;
                        break;

                    case QuestType.Guild:
                        icon = QuestStatusIcon.RewardGuildQuest;
                        break;
                    }

                    new SpNpcIcon(npc, icon, 1).Send(player.Connection);
                    return;
                }
            }

            //Talk
            {
                bool isTalk = false;

                foreach (var data in player.Quests)
                {
                    QStepDefault step = Quests[data.Key].GetNowStep(player);

                    if (step == null)
                    {
                        continue;
                    }

                    List <int> villagers = step.GetParticipantVillagers(player);

                    if (villagers.Count > 0 && npc.NpcTemplate.FullId == villagers[0])
                    {
                        if (Data.Data.Quests[data.Key].Type < questType)
                        {
                            questType = Data.Data.Quests[data.Key].Type;
                            isTalk    = true;

                            if (questType == 0)
                            {
                                break;
                            }
                        }
                    }
                }

                if (isTalk)
                {
                    switch (questType)
                    {
                    case QuestType.Mission:
                        icon = QuestStatusIcon.ProgressMissionQuest;
                        break;

                    case QuestType.Normal:
                        icon = QuestStatusIcon.ProgressNormalQuest;
                        break;

                    case QuestType.Guild:
                        icon = QuestStatusIcon.ProgressGuildQuest;
                        break;
                    }

                    new SpNpcIcon(npc, icon, 1).Send(player.Connection);
                    return;
                }
            }

            //Start
            if (NpcStartQuests.ContainsKey(npc.NpcTemplate.FullId))
            {
                bool isStart = false;

                for (int i = 0; i < NpcStartQuests[npc.NpcTemplate.FullId].Count; i++)
                {
                    Quest quest = NpcStartQuests[npc.NpcTemplate.FullId][i];

                    if (player.Quests.ContainsKey(quest.QuestId))
                    {
                        continue;
                    }

                    if (!quest.NeedClasses.Contains(player.PlayerData.Class))
                    {
                        continue;
                    }

                    if (quest.NeedLevel > player.Level)
                    {
                        continue;
                    }

                    isStart = true;

                    if (quest.Type < questType)
                    {
                        questType = quest.Type;
                    }

                    if (questType == 0)
                    {
                        break;
                    }
                }

                if (isStart)
                {
                    switch (questType)
                    {
                    case QuestType.Mission:
                        icon = QuestStatusIcon.MissionQuest;
                        break;

                    case QuestType.Normal:
                        icon = QuestStatusIcon.NormalQuest;
                        break;

                    case QuestType.Guild:
                        icon = QuestStatusIcon.GuildQuest;
                        break;
                    }
                }
            }

            if (icon != QuestStatusIcon.None)
            {
                new SpNpcIcon(npc, icon, 1).Send(player.Connection);
            }
            else if (force)
            {
                new SpNpcIcon(npc, 0, 0).Send(player.Connection);
            }
        }
Example #35
0
 /// <summary>
 /// Creates a new instance of the <see cref="NpcAggressiveAI"/> class.
 /// </summary>
 /// <param name="owner"></param>
 public NpcAggressiveAI(Npc owner)
     : base(owner)
 {
 }
Example #36
0
        public static int getNPCHitDelay(Npc npc)
        {
            /*switch (npc.getId())
            {

            }*/
            return 450;
        }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NpcTrader"/> class.
 /// </summary>
 /// <param name="npcRow">The NPC row reference.</param>
 public NpcTrader(Npc npcRow)
     : base(npcRow)
 {
 }
Example #38
0
        public override float Process(Npc npc)
        {
            if (!npc.NPCPlayer.ReferenceHub.characterClassManager.IsAnyScp())
            {
                if (npc.AvailableWeapons.Count > 0)
                {
                    if (!npc.ItemHeld.IsWeapon(false))
                    {
                        npc.ItemHeld = npc.AvailableWeapons.Keys.ElementAt(0);
                        return(0.5f);
                    }

                    npc.Stop();
                    Vector3    heading = (npc.CurrentAIPlayerTarget.Position - npc.NPCPlayer.Position);
                    Quaternion lookRot = Quaternion.LookRotation(heading.normalized);
                    npc.NPCPlayer.Rotations = new Vector2(lookRot.eulerAngles.x, lookRot.eulerAngles.y);
                    bool       miss         = Plugin.Random.Next(0, 100) >= accuracy;
                    int        hitbox_value = Plugin.Random.Next(0, 100);
                    HitBoxType hitbox       = HitBoxType.NULL;
                    int        min          = int.MaxValue;
                    foreach (HitBoxType box in hitboxes.Keys)
                    {
                        if (hitbox_value < hitboxes[box] && hitboxes[box] <= min)
                        {
                            min    = hitboxes[box];
                            hitbox = box;
                        }
                    }

                    npc.NPCPlayer.ReferenceHub.weaponManager.CallCmdShoot(miss ? npc.gameObject : npc.CurrentAIPlayerTarget.GameObject, hitbox, npc.NPCPlayer.CameraTransform.forward, npc.NPCPlayer.Position, npc.CurrentAIPlayerTarget.Position);

                    bool end = !npc.CurrentAIPlayerTarget.IsAlive;

                    if (use_ammo)
                    {
                        npc.AvailableWeapons[npc.ItemHeld]--;
                        if (npc.AvailableWeapons[npc.ItemHeld] <= 0)
                        {
                            npc.NPCPlayer.ReferenceHub.weaponManager.RpcReload(npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon);
                            npc.AvailableWeapons[npc.ItemHeld] = (int)npc.NPCPlayer.ReferenceHub.weaponManager.weapons[npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon].maxAmmo;
                            if (end)
                            {
                                npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                                IsFinished = true;
                            }
                            return(npc.NPCPlayer.ReferenceHub.weaponManager.weapons[npc.NPCPlayer.ReferenceHub.weaponManager.curWeapon].reloadingTime);
                        }
                    }


                    if (end)
                    {
                        npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                        IsFinished = true;
                        return(0f);
                    }
                }
                else
                {
                    IsFinished = true;
                    return(0f);
                }
                return(firerate * Plugin.Instance.Config.NpcFireCooldownMultiplier * npc.NPCPlayer.ReferenceHub.weaponManager._fireCooldown);
            }
            else
            {
                float cd = 0f;
                npc.OnTargetLostBehaviour = Npc.TargetLostBehaviour.STOP;
                npc.Follow(npc.CurrentAIPlayerTarget);
                if (Vector3.Distance(npc.CurrentAIPlayerTarget.Position, npc.NPCPlayer.Position) <= 1.5f)
                {
                    if (npc.NPCPlayer.Role.Is939())
                    {
                        npc.NPCPlayer.GameObject.GetComponent <Scp939PlayerScript>().CallCmdShoot(npc.CurrentAIPlayerTarget.GameObject);
                    }
                    else
                    {
                        switch (npc.NPCPlayer.Role)
                        {
                        case RoleType.Scp106:
                            npc.NPCPlayer.GameObject.GetComponent <Scp106PlayerScript>().CallCmdMovePlayer(npc.CurrentAIPlayerTarget.GameObject, ServerTime.time);
                            cd = 2f;
                            break;

                        case RoleType.Scp173:
                            npc.NPCPlayer.GameObject.GetComponent <Scp173PlayerScript>().CallCmdHurtPlayer(npc.CurrentAIPlayerTarget.GameObject);
                            break;

                        case RoleType.Scp049:
                            npc.CurrentAIPlayerTarget.Hurt(99999f, DamageTypes.Scp049, npc.NPCPlayer.Nickname);
                            cd = PlayableScps.Scp049.KillCooldown;
                            break;

                        case RoleType.Scp0492:
                            npc.NPCPlayer.GameObject.GetComponent <Scp049_2PlayerScript>().CallCmdShootAnim();
                            npc.NPCPlayer.GameObject.GetComponent <Scp049_2PlayerScript>().CallCmdHurtPlayer(npc.CurrentAIPlayerTarget.GameObject);
                            cd = 1f;
                            break;

                        case RoleType.Scp096:
                            npc.CurrentAIPlayerTarget.Hurt(99999f, DamageTypes.Scp096, npc.NPCPlayer.Nickname, npc.NPCPlayer.Id);
                            break;
                        }
                    }
                    if (!npc.CurrentAIPlayerTarget.IsAlive)
                    {
                        npc.AttachedCoroutines.Add(MEC.Timing.CallDelayed(0.1f, () =>
                        {
                            npc.FireEvent(new Events.NPCTargetKilledEvent(npc, npc.CurrentAIPlayerTarget));
                        }));

                        npc.Stop();

                        Player target = npc.CurrentAIPlayerTarget;

                        npc.CurrentAIPlayerTarget = null;

                        if (npc.ProcessSCPLogic && npc.NPCPlayer.Role == RoleType.Scp049)
                        {
                            npc.AttachedCoroutines.Add(Timing.RunCoroutine(ReviveCoroutine(npc, target)));
                            IsFinished = true;
                            return(PlayableScps.Scp049.TimeToRevive + 0.5f);
                        }
                    }
                }
                return(cd);
            }
        }
Example #39
0
        // collision handling beef
        private void SpatialCollision()
        {
            foreach (var team in BoundingBoxLocations.BoundingBoxLocationMap.Keys)
            {
                BoundingBoxLocations.BoundingBoxLocationMap[team].Clear();
            }

            foreach (var spriteA in Collidable)
            {
                // set the current region
                foreach (var region in BoundingBoxLocations.RegionMap)
                {
                    if (spriteA.regionKey != region.Key && region.Value.Bounds.Intersects(spriteA.GetBoundingBox()))
                    {
                        spriteA.regionKey = region.Key;
                    }
                }

                Polygon polyA = null;

                Target targetEntry = new Target();
                targetEntry.interiorId = spriteA.inInteriorId;
                targetEntry.targetLoc  = spriteA.GetBoundingBox().Center.ToVector2();
                if (spriteA.mapCordPoint != null)
                {
                    targetEntry.mapCordPoint = spriteA.mapCordPoint.Value;
                }
                // BoundBoxLocationMap update - this structure is used for AI locating targets. Set all needed target values
                // pathType denotes what pathType ai will move to. ( i.e. Ships won't move to targets with Land pathType because it wouldn't find a path there and would waste time)
                if (spriteA.GetType().BaseType == typeof(Gusto.Models.Animated.Ship))
                {
                    Ship ship = (Ship)spriteA;
                    targetEntry.pathType = PathType.Ocean;
                    BoundingBoxLocations.BoundingBoxLocationMap[ship.teamType].Add(targetEntry);
                }
                else if (spriteA.GetType().BaseType == typeof(Gusto.Models.Animated.Tower))
                {
                    Tower tower = (Tower)spriteA;
                    targetEntry.pathType = PathType.Land;
                    BoundingBoxLocations.BoundingBoxLocationMap[tower.teamType].Add(targetEntry);
                }
                else if (spriteA.GetType().BaseType == typeof(Gusto.Models.Animated.PlayerPirate))
                {
                    PlayerPirate player = (PlayerPirate)spriteA;
                    targetEntry.pathType = PathType.Land;
                    BoundingBoxLocations.BoundingBoxLocationMap[player.teamType].Add(targetEntry);
                }
                else if (spriteA.GetType().BaseType == typeof(Gusto.Models.Animated.Npc))
                {
                    Npc npc = (Npc)spriteA;
                    targetEntry.pathType = PathType.Land;
                    BoundingBoxLocations.BoundingBoxLocationMap[npc.teamType].Add(targetEntry);
                }

                Rectangle bbA = spriteA.GetBoundingBox();
                if (BoundingBoxTextures.DynamicBoundingPolygons.ContainsKey(spriteA.bbKey))
                {
                    polyA = spriteA.GetBoundingPolygon();
                }

                HashSet <string> quadKeys = collision.GetQuadKey(bbA);
                HashSet <Sprite> possible = new HashSet <Sprite>();
                foreach (var key in quadKeys)
                {
                    possible.UnionWith(collision.GetSpatialBoundingMap()[key]);
                }

                foreach (var spriteB in possible)
                {
                    var bbB = spriteB.GetBoundingBox();

                    if (Object.ReferenceEquals(spriteA, spriteB))
                    {
                        continue;
                    }

                    Polygon polyB = null;
                    if (BoundingBoxTextures.DynamicBoundingPolygons.ContainsKey(spriteB.bbKey))
                    {
                        polyB = spriteB.GetBoundingPolygon();
                    }

                    // pass collision game logic - this filters out some collisions that are colliding but we don't want to handle a collision (trees colliding with other trees)
                    if (CollisionGameLogic.CheckCollidable(spriteA, spriteB) && CollisionGameLogic.CheckCollidable(spriteB, spriteA))
                    {
                        // spatial intersection for rect, poly
                        if (polyA != null || polyB != null)
                        {
                            // poly vs rect
                            if (polyA != null && polyB == null)
                            {
                                if (polyA.IntersectsRect(bbB))
                                {
                                    MarkCollision(spriteA, spriteB);
                                }
                            }
                            else if (polyB != null && polyA == null)
                            {
                                if (polyB.IntersectsRect(bbA))
                                {
                                    MarkCollision(spriteA, spriteB);
                                }
                            }
                            else
                            {
                                // poly vs poly
                                if (polyA.IntersectsPoly(polyB))
                                {
                                    MarkCollision(spriteA, spriteB);
                                }
                            }
                        }
                        else
                        {
                            // rect vs rects
                            if (bbA.Intersects(bbB))
                            {
                                MarkCollision(spriteA, spriteB);
                            }
                        }
                    }
                }
            }
            collision.Clear();
        }
Example #40
0
        public static void fightCaveAttacks(Npc npc, Player p)
        {
            if (npc.isDead() || npc.isDestroyed() || p.isDead() || p.isDestroyed() || p.isDead() || !Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
            {
                return;
            }
            int damage    = Misc.random(npc.getMaxHit());
            int prayer    = p.getPrayers().getHeadIcon();
            int hitDelay  = npc.getHitDelay();
            int animation = npc.getAttackAnimation();

            switch (npc.getId())
            {
            case 2734:     // Tz-Kih (lvl 22)
            case 2735:
                if (prayer == PrayerData.MELEE)
                {
                    damage = 0;
                }
                break;

            case 2739:     // Tz-Xil (lvl 90)
            case 2740:
                if (prayer == PrayerData.RANGE)
                {
                    damage = 0;
                }
                p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1616, 50, 40, 34, 50, p);
                break;

            case 2741:     // Yt-MejKot (lvl 180)
            case 2742:
                if (prayer == PrayerData.MELEE)
                {
                    damage = 0;
                }
                // TODO healing
                break;

            case 2743:     // Ket-Zek (lvl 360)
            case 2744:
                if (!p.getLocation().withinDistance(npc.getLocation(), 2))
                {
                    hitDelay  = 1600;
                    animation = 9266;
                    npc.setLastGraphics(new Graphics(1622));
                    damage = Misc.random(49);
                    if (prayer == PrayerData.MAGIC)
                    {
                        damage = 0;
                    }
                    Event sendProjectileToNpc = new Event(300);
                    sendProjectileToNpc.setAction(() =>
                    {
                        sendProjectileToNpc.stop();
                        p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1623, 50, 40, 34, 80, p);
                    });
                    Server.registerEvent(sendProjectileToNpc);
                }
                else
                {
                    damage = Misc.random(64);
                    if (prayer == PrayerData.MELEE)
                    {
                        damage = 0;
                    }
                }
                break;

            case 2745:     // TzTok Jad (lvl 702)
                doJadAttacks(p, npc);
                break;
            }
            if (npc.getId() == 2745)
            {
                return;
            }
            if (animation != 65535)
            {
                npc.setLastAnimation(new Animation(animation));
            }
            p.setLastAttacked(Environment.TickCount);
            npc.setLastAttack(Environment.TickCount);
            p.setAttacker(npc);
            npc.resetCombatTurns();
            if (damage > p.getHp())
            {
                damage = p.getHp();
            }
            int npcId = npc.getId();

            Event losePrayerFightingEvent = new Event(hitDelay);

            losePrayerFightingEvent.setAction(() =>
            {
                losePrayerFightingEvent.stop();
                if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                {
                    return;
                }
                if (npcId == 2734 || npcId == 2735)
                {
                    int prayerLevel    = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                    int newPrayerLevel = prayerLevel -= (damage + 1);
                    if (newPrayerLevel <= 0)
                    {
                        newPrayerLevel = 0;
                    }
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayerLevel);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                }
                else if (npcId == 2743 || npcId == 2744)
                {
                    if (Misc.random(1) == 0)
                    {
                        p.setLastGraphics(new Graphics(1624, 0));
                    }
                }
                if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                {
                    p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                }
                p.hit(damage);
            });
            Server.registerEvent(losePrayerFightingEvent);
        }
Example #41
0
        public override void Execute(Npc npc, Character character)
        {
            var dialog = new NpcDofusTalkDialog(character, npc);

            dialog.Open();
        }
Example #42
0
    //TODO: Method to be re written when serialisation/deserialisation implemented.
    private void InstantiateNpc(Npc newNpc)
    {
        GameObject npcGameObject = Instantiate (Resources.Load ("Prefabs/NPC"), newNpc.CurrentStartPosition, Quaternion.identity) as GameObject;
        npcGameObject.name = newNpc.Name;

        NpcAdapter adapter = npcGameObject.GetComponent<NpcAdapter> ();
        adapter.Npc = newNpc;
        GameObject holder = GameObject.Find ("NPCs");
        npcGameObject.transform.parent = holder.transform;
    }
Example #43
0
 public NpcDofusExchangeDialog(Character character, Npc npc)
     : base(character, npc)
 {
 }
Example #44
0
 public static bool openPointsInterface(Player p, Npc npc)
 {
     int id = npc.getId();
     if (id != 8273 && id != 1597 && id != 8274 && id != 1598 && id != 8275 || p.isDead()) {
         return false;
     }
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent openPointsInterfaceAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
     openPointsInterfaceAreaEvent.setAction(() => {
         p.setEntityFocus(65535);
         npc.setFaceLocation(p.getLocation());
         displayPoints(p, 1);
     });
     Server.registerCoordinateEvent(openPointsInterfaceAreaEvent);
     return true;
 }
Example #45
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (GUI_Start.Start)
            return;

        if (hit == true)
        {
            hitcount--;
            if (hitcount <= 0)
            {
                hitcount = hitTimer;
                hit = false;
            }
        }
        if (hit == true)
        {
            for (int i = 0; i < Sprite.Length; i++)
            {
                Sprite[i].color = hurted;
            }
        }
        else
        {
            for (int i = 0; i < Sprite.Length; i++)
            {
                Sprite[i].color = self;
            }
        }

        if (Health <= 0)
        {
            if (hit == false)
            {
                for (int i = 0; i < Sprite.Length; i++)
                    Sprite[i].enabled = false;

                if (Name == Get.TargetName)
                {
                    if (isServer)
                        Player.play.RpcEndGame();
                    else Player.play.CmdEndGame();
                } else
                {
                    if (isServer)
                        Player.play.RpcDestroyUnit(id);
                    else
                        Player.play.CmdDestroyUnit(id);
                }
            }
        }

        #region Afraid
        if (State == states.Afraid)
        {
            if (Afraidof != null)
            {
                float distance = Vector3.Distance(transform.position,Afraidof.position);
                if (distance < 10f)
                {
                        Unit.MoveTo(RunAway());
                } else {
                    State = states.Idle;
                    Suspicion = 0;
                    offender = Afraidof.gameObject.GetComponent<Player>();
                    offender.IsSeen = false;
                    offender = null;
                    Afraidof = null;
                }
            }
        }
        #endregion
        #region Hurt
        if (hurtstart == true)
        {
            hurt -= 0.1f;
            if (hurt <= 0)
            {
                RevertColor();
                hurt = 1f;
                hurtstart = false;
            }
        }
        #endregion
        #region Offended
        /*else if (State == states.Idle && offender != null)
        {
            Watch++;
            if (Watch >= 5f)
            {
                State = states.SearchingForGuard;
            }
        } */
        #endregion
        #region Idle
        else if (State == states.Idle);
        {
            if (counter <= 0)
            {
                if (mingler != null)
                {
                    float distance = Vector3.Distance(mingler.transform.position, transform.position);
                    if (distance > 1f)
                    {
                        Unit.MoveTo(mingler.transform.position);
                    } else
                    {
                        counter = SetCounter;
                        State = states.Talking;
                    }
                }

                    for (int i = 0; i < needs.Length; i++)
                    {
                        if (needs[i] <= Crave)
                            GetNeedState(i);
                    }
                    if (State == states.Idle)
                    {
                        direction = Move[Random.Range(0, Move.Length)];
                        Vector3 move = direction + new Vector3(direction.x * Random.Range(1f, 20f), direction.y * Random.Range(1f, 12f), -0.1f);
                        bool walkable = (Physics.CheckSphere(move, 0.5f, layermask));
                        if (walkable)
                        {
                            State = states.Walk;
                            Unit.MoveTo(move);
                        }
                        else
                        {
                            counter = SetCounter;
                        }
                    }

                }
        }
        #endregion
        #region Walking
        if (State == states.Walk)
        {
            if (Unit.path.Length > 0)
            {
            if (Unit.path.Length > 0 && transform.position == Unit.path[Unit.path.Length-1])
                {
                counter = SetCounter;
                State = states.Idle;
                if (Suspicion > 0)
                    Suspicion -= 5;
                }
            } else {
                counter = SetCounter;
                State = states.Idle;
            }
        }
        #endregion
        #region Talking
        if (State == states.Talking)
        {
            if (mingler != null)
            {

                if (counter <= 0)
                {
                    State = states.Idle;
                    mingler = null;
                }
            }
            if (offender != null)
            {
                InvokeRepeating("Talk", convoLength, 1.0f);
                if (conversation <= 0)
                {
                    Namerender.text = Name;
                }
            }
        }
        #endregion
        #region SearchingForGuard
        /*	if (State == states.SearchingForGuard)
        {
            if (Search == null)
                Search  = GameObject.FindObjectsOfType(typeof(Guard)) as Guard[];
            else {
                if (Search.Length > 0)
                {
                    bool walkable = (Physics.CheckSphere(Search[0].transform.position, 0.5f, layermask));
                    if (walkable)
                        Unit.MoveTo(Search[0].transform.position);
                    float distance = Vector3.Distance(Search[0].transform.position, transform.position);
                    if (distance < 1f)
                    {
                        Unit.MoveTo(transform.position);
                        State = states.Reporting;
                    }
                }
            }
        }*/
        #endregion
        /*	#region ReportingToGuard
        if (State == states.Reporting)
        {
            Search[0].Target = offender;
            State = states.Idle;
        }
        #endregion*/
        #region Drink
        if (State == states.Drink)
        {
            if (SearchingforArea == null)
            {
                SearchingforArea = GameObject.Find("Drink_Area");
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (Unit.path.Length > 0 && transform.position == Unit.path[Unit.path.Length - 1])
            {
                needs[2] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }
            /*if (Items == null)
                Items  = GameObject.FindObjectsOfType(typeof(Item)) as Item[];
            else if (Needs[3].Meter <= 0)
            {
                Item drink = null;
                for (int i = 0; i < Items.Length;i++)
                {
                    if (Items[i].Type == Item.type.Spawn && Items[i].Loot != null && Items[i].Loot.name == "Drink")
                    {
                        drink = Items[i];
                        break;
                    } else if (Items[i].IsConsumable == Item.consumable.Drink)
                    {
                        drink = Items[i];
                        break;
                    }
                }
                SearchingforArea = drink.gameObject;
                float distance = Vector2.Distance(drink.transform.position,transform.position);
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (transform.position == Unit.path[Unit.path.Length-1])
            {
                needs[3] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }*/
        }
        #endregion
        #region Bathroom
        if (State == states.Bathroom)
        {
            if (SearchingforArea == null)
            {
                SearchingforArea  = GameObject.Find("Toilet_Area");
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (Unit.path.Length > 0 && transform.position == Unit.path[Unit.path.Length-1])
            {
                needs[2] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }
        }
        #endregion
        #region Hungry
        if (State == states.Hungry)
        {
            if (SearchingforArea == null)
            {
                SearchingforArea = GameObject.Find("Food_Area");
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (Unit.path.Length > 0 && transform.position == Unit.path[Unit.path.Length - 1])
            {
                needs[2] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }
            /*if (SearchingforArea == null)
            {
                SearchingforArea  = GameObject.Find("Food");
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (transform.position == Unit.path[Unit.path.Length-1])
            {
                needs[0] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }*/
        }
        #endregion
        #region Smoke
        if (State == states.Smoke)
        {
            if (SearchingforArea == null)
            {
                SearchingforArea  = GameObject.Find("Smoking_Area");
                Unit.MoveTo(SearchingforArea.transform.position);
            }

            if (Unit.path.Length > 0 && SearchingforArea != null && transform.position == Unit.path[Unit.path.Length-1])
            {
                needs[1] = 100;
                SearchingforArea = null;
                State = states.Idle;
            }
        }
        #endregion
    }
Example #46
0
 public static bool talkToMaster(Player p, Npc npc)
 {
     for (int i = 0; i < SLAYER_MASTERS.Length; i++) {
         if (npc.getId() == (int)SLAYER_MASTERS[i][0]) {
             int j = i;
             p.setEntityFocus(npc.getClientIndex());
             AreaEvent talkToMasterAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
             talkToMasterAreaEvent.setAction(() => {
                 p.setTemporaryAttribute("slayerMaster", j);
                 npc.setFaceLocation(p.getLocation());
                 p.setFaceLocation(npc.getLocation());
                 p.setEntityFocus(65535);
                 doDialogue(p, 1000);
             });
             Server.registerCoordinateEvent(talkToMasterAreaEvent);
             return true;
         }
     }
     return false;
 }
Example #47
0
        private static void thieveNpc(Player p, Npc npc, int index)
        {
            AreaEvent thieveNpcAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
            thieveNpcAreaEvent.setAction(() => {
                if (!canThieveNpc(p, npc, index)) {
                    return;
                }
                p.setFaceLocation(npc.getLocation());
                p.setLastAnimation(new Animation(881));
                p.getPackets().sendMessage("You attempt to pick the " + NPC_NAMES[index] + " pocket...");
                p.setTemporaryAttribute("lastPickPocket", Environment.TickCount);

                Event thieveNpcEvent = new Event(1000);
                thieveNpcEvent.setAction(() => {
                    thieveNpcEvent.stop();
                    if (!p.getLocation().withinDistance(npc.getLocation(), 2)) {
                        return;
                    }
                    if (successfulThieve(p, index, false)) {
                        int rewardIndex = misc.random(NPC_REWARD[index].Length - 1);
                        int reward = NPC_REWARD[index][rewardIndex];
                        int rewardAmount = NPC_REWARD_AMOUNT[index][rewardIndex];
                        if (index == 7) { // Master farmer.
                            if (misc.random(15) == 0) {
                                reward = HERB_SEEDS[misc.random(HERB_SEEDS.Length - 1)];
                            }
                        }
                        p.getSkills().addXp(Skills.SKILL.THIEVING, NPC_XP[index]);
                        p.getInventory().addItem(reward, rewardAmount);
                        p.getPackets().sendMessage("You pick the " + NPC_NAMES[index] + " pocket.");
                    } else {
                        p.getWalkingQueue().resetWalkingQueue();
                        p.getPackets().sendMessage("You fail to pick the " + NPC_NAMES[index] + " pocket.");
                        p.getPackets().sendMessage("You've been stunned!");
                        npc.setForceText("What do you think you're doing?");
                        p.setTemporaryAttribute("unmovable", true);
                        p.setTemporaryAttribute("stunned", true);
                        p.setLastGraphics(new Graphics(80, 0, 100));
                        p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                        p.hit(1);
                        npc.setFaceLocation(p.getLocation());
                        Event removeStunEvent = new Event(5000);
                        removeStunEvent.setAction(() => {
                            removeStunEvent.stop();
                            p.removeTemporaryAttribute("unmovable");
                            p.removeTemporaryAttribute("stunned");
                            p.setLastGraphics(new Graphics(65535));
                        });
                        Server.registerEvent(removeStunEvent);
                    }
                });
                Server.registerEvent(thieveNpcEvent);
            });
            Server.registerCoordinateEvent(thieveNpcAreaEvent);
        }
 /// <summary>
 /// add deliver objective to quest, one objective of this type per quest.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="deliverTarget"></param>
 public void AddDeliverObjective(QuestItem item, Npc deliverTarget)
 {
     m_objectives.Add(QuestObjectiveType.Deliver, new QuestObjectiveDeliver(item, deliverTarget));
     m_description += m_objectives[QuestObjectiveType.Deliver].ToString();
 }
 /// <summary>
 /// Set quest return/handin npc, can be the same as the quest giver or another npc
 /// </summary>
 /// <param name="questReturn"></param>
 public void SetQuestReturn(Npc questReturn)
 {
     m_questReturn = questReturn;
 }
Example #50
0
 public SpPlayerExpAndPointUp(Player p, long added = 0, Npc npc = null)
 {
     Player = p;
     Added  = added;
     Npc    = npc;
 }
Example #51
0
 /// <summary>
 /// Zaps an NPC once. Taunts are designed primarily for drawing the attention of NPCs,
 /// not damaging them. Though taunts are useful for Mages for finishing off Venom targets.
 /// </summary>
 /// <param name="target">The NPC to target for the attack.</param>
 /// <param name="isLowCostSpell">If true, a minor mana restoration item will be used if the
 /// caster lacks sufficient mana to cast the spell. If false, a major mana restoration item
 /// will be used instead.</param>
 /// <returns>True if a spell is cast. False otherwise.</returns>
 public async Task <bool> Taunt(Npc target, bool isLowCostSpell = true)
 {
     return(await Zap(target, true));
 }
Example #52
0
 /// <summary>
 /// Casts a curse (i.e. Vex or Scourge) on a target.
 /// </summary>
 /// <param name="target">The NPC to target for the debuff.</param>
 /// <returns>True if the spell was cast; false otherwise.</returns>
 public virtual async Task <bool> Curse(Npc target)
 {
     return(await StatusCommands.CastStatus(_self, target, target.Activity.Curse, CurseSpell));
 }
Example #53
0
 public static bool openSlayerShop(Player p, Npc npc)
 {
     int id = npc.getId();
     if (id != 8273 && id != 1597 && id != 8274 && id != 1598 && id != 8275 || p.isDead()) {
         return false;
     }
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent openSlayerShopAreaEvent = new AreaEvent(p, npc.getLocation().getX()-1, npc.getLocation().getY()-1, npc.getLocation().getX()+1, npc.getLocation().getY()+1);
     openSlayerShopAreaEvent.setAction(() => {
         p.setFaceLocation(npc.getLocation());
         npc.setFaceLocation(p.getLocation());
         p.setShopSession(new ShopSession(p, 2));
     });
     Server.registerCoordinateEvent(openSlayerShopAreaEvent);
     return true;
 }
Example #54
0
 /// <summary>
 /// Zaps a target for ranged magic damage.
 /// </summary>
 /// <param name="target">The NPC to target for the attack.</param>
 /// <param name="isLowCostSpell">If true, a minor mana restoration item will be used if the
 /// caster lacks sufficient mana to cast the spell. If false, a major mana restoration item
 /// will be used instead.</param>
 /// <returns>True if a spell is cast. False otherwise.</returns>
 public async Task <bool> Zap(Npc target, bool isLowCostSpell = false)
 {
     return(await SpellCommands.CastTargetableSpell(Self, ZapSpell, target, isLowCostSpell));
 }
 public NpcAI(Npc npc)
 {
     Npc = npc;
 }
 public QuestObjectiveDeliver(QuestItem item, Npc deliverTarget)
 {
     m_deliverables = item;
 }
Example #57
0
 public NpcExchange(WorldClient Client, Npc Npc)
 {
     this.myClient = Client;
     this.Npc      = Npc;
 }
Example #58
0
        protected override void Process(GameSession session, In packet)
        {
            Map map = session.Character.Map;

            Entity entity;

            switch (packet.EntityType)
            {
            case EntityType.Monster:
                Monster monster = entityFactory.CreateMonster(packet.ModelId, packet.EntityId);

                monster.Position     = packet.Position;
                monster.HpPercentage = packet.Npc.HpPercentage;
                monster.MpPercentage = packet.Npc.MpPercentage;
                monster.Map          = map;

                monster.Map.Monsters[monster.Id] = monster;
                entity = monster;
                break;

            case EntityType.Npc:
                Npc npc = entityFactory.CreateNpc(packet.ModelId, packet.EntityId, packet.Npc.Name);

                npc.Position     = packet.Position;
                npc.HpPercentage = packet.Npc.HpPercentage;
                npc.MpPercentage = packet.Npc.MpPercentage;
                npc.Map          = map;

                npc.Map.Npcs[npc.Id] = npc;
                entity = npc;

                OwnedPet pet = session.Character.Pets.FirstOrDefault(x => x.EntityId == entity.Id && x.IsTeamMember);
                if (pet != null)
                {
                    session.Character.Pet = new Pet(session.Character, pet, npc);
                }
                break;

            case EntityType.MapObject:
                MapObject mapObject = entityFactory.CreateMapObject(packet.ModelId, packet.EntityId, packet.MapObject.Amount);
                Player    owner     = map.GetEntity <Player>(EntityType.Player, packet.MapObject.Owner);
                if (owner == null)
                {
                    Log.Debug($"Can't found owner of map object {mapObject.Id}");
                }

                mapObject.Position = packet.Position;
                mapObject.Owner    = owner;
                mapObject.Map      = map;

                mapObject.Map.MapObjects[mapObject.Id] = mapObject;
                entity = mapObject;
                break;

            case EntityType.Player:
                var player = new Player(packet.EntityId, packet.Name)
                {
                    Gender       = packet.Player.Gender,
                    Job          = packet.Player.Job,
                    HpPercentage = packet.Player.HpPercentage,
                    MpPercentage = packet.Player.MpPercentage,
                    Position     = packet.Position,
                    Level        = packet.Player.Level,
                    HeroLevel    = packet.Player.HeroLevel,
                    Map          = map
                };

                player.Map.Players[player.Id] = player;
                entity = player;
                break;

            default:
                return;
            }

            eventPipeline.Process(session, new EntityJoinEvent
            {
                Entity = entity,
                Map    = map
            });

            Log.Trace($"Entity {packet.EntityType} with ID {packet.EntityId} added to map.");
        }
Example #59
0
 public static byte GetNPCIcon(ActorPC pc, Npc npc)
 {
     byte icon = 0;
     SagaDB.Quest.Quest q = Quest.QuestsManager.GetActiveQuest(pc);
     if (q != null)
     {
         if (npc.Questtable.ContainsKey(q.ID))
         {
             foreach (SagaDB.Quest.Step s in npc.Questtable[q.ID].Steps.Values)
             {
                 if (s.Status == Quest.QuestsManager.GetQuestStepStatus(pc, q.ID, s.ID))
                 {
                     icon += 2;
                 }
                 if (icon >= 2) break;
             }
         }
     }
     Npc.QuestReqirement pq = npc.GetAvaluablePersonalQuest(pc);
     if (pq != null)
     {
         icon += 1;
     }
     q = QuestsManager.GetActivePersonalQuest(pc);
     if (icon != 3 && icon !=2)
     {
         if (q != null)
         {
             if (npc.PersonalQuesttable.ContainsKey(q.ID))
             {
                 foreach (SagaDB.Quest.Step s in npc.PersonalQuesttable[q.ID].Steps.Values)
                 {
                     if (s.Status == Quest.QuestsManager.GetQuestStepStatus(pc, q.ID, s.ID))
                     {
                         icon += 2;
                     }
                     if (icon >= 2) break;
                 }
             }
         }
     }
     return icon;
 }
Example #60
0
        private static void doJadAttacks(Player p, Npc npc)
        {
            if (npc.getHp() <= (npc.getMaxHp() * 0.50))
            {
                if (p.getFightCave() != null)
                {
                    if (!p.getFightCave().isHealersSpawned())
                    {
                        summonJadHealers(p, npc);
                        p.getFightCave().setHealersSpawned(true);
                    }
                }
            }
            npc.resetCombatTurns();
            npc.setEntityFocus(p.getClientIndex());
            switch (Misc.random(1))
            {
            case 0:     // Range
                npc.setLastAnimation(new Animation(9276));
                npc.setLastGraphics(new Graphics(1625));
                Event jadRangeAttackEvent  = new Event(1600);
                int   jadRangeAttackStatus = 0;
                jadRangeAttackEvent.setAction(() =>
                {
                    int hit    = 0;
                    int prayer = p.getPrayers().getHeadIcon();
                    if (jadRangeAttackStatus == 0)
                    {
                        jadRangeAttackStatus++;
                        jadRangeAttackEvent.setTick(1500);
                        p.setLastGraphics(new Graphics(451));
                        if (prayer == PrayerData.RANGE)
                        {
                            hit = 0;
                        }
                        else
                        {
                            hit = Misc.random(96);
                        }
                    }
                    else
                    {
                        if (prayer != PrayerData.RANGE)
                        {
                            hit = Misc.random(96);
                        }
                        jadRangeAttackEvent.stop();
                        p.setLastAttacked(Environment.TickCount);
                        npc.setLastAttack(Environment.TickCount);
                        p.setAttacker(npc);
                        if (hit > p.getHp())
                        {
                            hit = p.getHp();
                        }
                        if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                        {
                            return;
                        }
                        if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                        {
                            p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                        }
                        p.hit(hit);
                        Event animationEvent = new Event(100);
                        animationEvent.setAction(() =>
                        {
                            animationEvent.stop();
                            p.setLastGraphics(new Graphics(157, 0, 100));
                        });
                        Server.registerEvent(animationEvent);
                    }
                });
                Server.registerEvent(jadRangeAttackEvent);
                break;

            case 1:     // Magic
                npc.setLastGraphics(new Graphics(1626));
                Event jadMagicAttackEvent  = new Event(300);
                int   jadMagicAttackStatus = 0;
                jadMagicAttackEvent.setAction(() =>
                {
                    int hit    = 0;
                    int prayer = p.getPrayers().getHeadIcon();
                    npc.setLastAnimation(new Animation(9278));
                    if (jadMagicAttackStatus == 0)
                    {
                        jadMagicAttackStatus++;
                        jadMagicAttackEvent.setTick(1600);
                        p.getPackets().sendProjectile(npc.getLocation(), p.getLocation(), 32, 1627, 50, 40, 34, 90, p);
                    }
                    else
                    {
                        jadMagicAttackEvent.stop();
                        if (prayer == PrayerData.MAGIC)
                        {
                            hit = 0;
                        }
                        else
                        {
                            hit = Misc.random(96);
                        }
                        p.setLastAttacked(Environment.TickCount);
                        npc.setLastAttack(Environment.TickCount);
                        p.setAttacker(npc);
                        if (hit > p.getHp())
                        {
                            hit = p.getHp();
                        }
                        if (!Location.inFightCave(p.getLocation()) || p.getTeleportTo() != null)
                        {
                            return;
                        }
                        if ((p.getCombatTurns() > 2 || p.getCombatTurns() < 0))
                        {
                            p.setLastAnimation(new Animation(p.getDefenceAnimation()));
                        }
                        p.hit(hit);
                        Event animationEvent = new Event(100);
                        animationEvent.setAction(() =>
                        {
                            animationEvent.stop();
                            p.setLastGraphics(new Graphics(157, 0, 100));
                        });
                        Server.registerEvent(animationEvent);
                    }
                });
                Server.registerEvent(jadMagicAttackEvent);
                break;
            }
        }