コード例 #1
0
 public void resetWalkingQueue()
 {
     walkingQueue[0].x   = player.getLocation().getLocalX();
     walkingQueue[0].y   = player.getLocation().getLocalY();
     walkingQueue[0].dir = -1;
     waypointReadOffset  = waypointWriteOffset = 1;
 }
コード例 #2
0
ファイル: SpawnObject.cs プロジェクト: Krill156/SharpEMU
        public void execute(Player player, string[] arguments)
        {
            //TODO: Possible TODO.
            //I guess this command is for testing where object should be placed to spawnedObjects.cfg / objectLocations.cfg?
              	        //Err I don't like this command too much as the objects spawned are fake..
            //gotta maybe add to WorldObjects, like SpawnNPC :S later.

            if (arguments.Length < 2)
            {
                player.getPackets().sendMessage("[SpawnObject command]: ::obj objectId face");
                return;
            }

            int objectId = 0;
            int face = 0;

            if(!int.TryParse(arguments[0], out objectId)) {
                player.getPackets().sendMessage("[SpawnObject command]: objectId is not a number ::obj objectId face");
                return;
            }

            if(!int.TryParse(arguments[1], out face)) {
                player.getPackets().sendMessage("[SpawnObject command]: face is not a number ::obj objectId face");
                return;
            }

            foreach(Player p in Server.getPlayerList()) {
                p.getPackets().createObject(objectId, player.getLocation(), face, 10);
            }
        }
コード例 #3
0
        public void addItemOrGround(int item, int amount)
        {
            /*
             * We try to add the item to the inventory..
             */
            if (addItem(item, amount))
            {
                return;
            }

            /*
             * It didn't add the item above, yet we have room for it?..odd.
             */
            if (getTotalFreeSlots() > 0)
            {
                return;
            }

            /*
             * Add the item to the ground.
             */
            GroundItem g = new GroundItem(item, amount, p.getLocation(), p);

            Server.getGroundItems().newEntityDrop(g);
        }
コード例 #4
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
 /*
  * The config to remove roofs is 1270
  * The door is 6713
  *
  * Random door configs
  * CONFIG = 452    0
    CONFIG = 452    32
    CONFIG = 452    96
    CONFIG = 452    16480
    CONFIG = 452    278624
    CONFIG = 452    802912
    CONFIG = 452    2900064
    CONFIG = 452    2637920
    CONFIG = 452    2638944
    CONFIG = 452    2640992
    CONFIG = 452    2645088
    CONFIG = 452    2653280
    CONFIG = 452    2649184
  */
 public static bool enterCrypt(Player p)
 {
     for (int i = 0; i < MOUND_COORDS.Length; i++) {
         for (int j = 0; j < MOUND_COORDS[i].Length; j++) {
             if (p.getLocation().inArea(MOUND_COORDS[i][0], MOUND_COORDS[i][1], MOUND_COORDS[i][2], MOUND_COORDS[i][3]) && p.getLocation().getZ() == 0)
             {
                 p.teleport(new Location(STAIR_COORDS[i][0], STAIR_COORDS[i][1], 3));
                 if (p.getBarrowTunnel() == -1) {
                     p.setBarrowTunnel(misc.random(5));
                 }
                 return true;
             }
         }
     }
     return false;
 }
コード例 #5
0
ファイル: Height.cs プロジェクト: Krill156/SharpEMU
        public void execute(Player player, string[] arguments)
        {
            if (arguments.Length == 0)
            {
                player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible");
                return;
            }

            int heightLevel = 0;
            if (!int.TryParse(arguments[0], out heightLevel))
            {
                player.getPackets().sendMessage("[Height command]: ::height 0 [0,1,2,3] are possible");
                return;
            }

            player.teleport(new Location(player.getLocation().getX(), player.getLocation().getY(), heightLevel));
        }
コード例 #6
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
 public static bool betweenDoors(Player p)
 {
     for (int i = 0; i < DB.Length; i++) {
         if (p.getLocation().inArea(DB[i][0], DB[i][1], DB[i][2], DB[i][3]))
         {
             return true;
         }
     }
     return false;
 }
コード例 #7
0
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation     = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX() + 1, cannonLocation.getY() + 1, cannonLocation.getY());
     firing             = false;
     cannonballs        = 0;
     constructionStage  = 0;
     direction          = 0;
     setNpcsInArea();
     newCannon();
 }
コード例 #8
0
ファイル: AlKharid.cs プロジェクト: Krill156/SharpEMU
 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);
 }
コード例 #9
0
ファイル: DwarfCannon.cs プロジェクト: Krill156/SharpEMU
 public DwarfCannon(Player player)
 {
     p = player;
     cannonLocation = p.getLocation();
     fakeCannonLocation = new Location(cannonLocation.getX()+1, cannonLocation.getY()+1, cannonLocation.getY());
     firing = false;
     cannonballs = 0;
     constructionStage = 0;
     direction = 0;
     setNpcsInArea();
     newCannon();
 }
コード例 #10
0
ファイル: BoatOptions.cs プロジェクト: Krill156/SharpEMU
        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;
        }
コード例 #11
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
 public static int getCryptIndex(Player p)
 {
     if (p.getLocation().inArea(3567, 9701, 3580, 9711)) {
         return VERAC;
     } else if (p.getLocation().inArea(3548, 9709, 3561, 9721)) {
         return DHAROK;
     } else if (p.getLocation().inArea(3549, 9691, 3562, 9706)) {
         return AHRIM;
     } else if (p.getLocation().inArea(3532, 9698, 3546, 9710)) {
         return GUTHAN;
     } else if (p.getLocation().inArea(3544, 9677, 3559, 9689)) {
         return KARIL;
     } else if (p.getLocation().inArea(3563, 9680, 3577, 9694)) {
         return TORAG;
     }
     return -1;
 }
コード例 #12
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
        private void handleItemOnObject(Player player, Packet packet)
        {
            int objectX = packet.readShortA();
            int item = packet.readUShort();
            int objectY = packet.readLEShort();
            int slot = packet.readUShort();
            int interfaceId = packet.readLEShort();
            int child = packet.readUShort();
            int objectId = packet.readShortA();
            if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            Console.WriteLine("Item on object = " + objectId + " " + objectX + " " + objectY);
            SkillHandler.resetAllSkills(player);
            player.getPackets().closeInterfaces();
            player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
            if (player.getInventory().getItemInSlot(slot) == item) {
                if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
                    return;
                } else if (Farming.interactWithPatch(player, objectId, objectX, objectY, player.getInventory().getItemInSlot(slot))) {
                    return;
                } else if (WarriorGuild.useAnimator(player, player.getInventory().getItemInSlot(slot), objectId, objectX, objectY)) {
                    return;
                }
                if (player.getInventory().getItemInSlot(slot) == 7936) {
                    if (RuneCraft.wantToRunecraft(player, objectId, objectX, objectY)) {
                        return;
                    }
                    if (RuneCraft.useTalisman(player, objectId, objectX, objectY)) {
                        return;
                    }
                }
                switch(objectId) {
                    case 6: // Cannon:
                        DwarfCannon cannon = player.getCannon();
                        Location l = new Location(objectX, objectY, player.getLocation().getZ());
                        if (cannon == null || (cannon != null & !l.withinDistance(cannon.getLocation(), 2))) {
                            player.getPackets().sendMessage("This isn't your cannon!");
                            break;
                        }
                        cannon.loadCannon();
                        break;

                    case 36781: // Lumbridge fountain.
                    case 24214:	// Fountain in east Varrock.
                    case 24265:	// Varrock main fountain.
                    case 11661:	// Falador waterpump.
                    case 11759:	// Falador south fountain.
                    case 879:	// Camelot fountains.
                    case 29529:	// Sink.
                    case 874:	// Sink.
                        if (FillVial.fillingVial(player, new Location(objectX, objectY, player.getLocation().getZ())) && player.getInventory().getItemInSlot(slot) == 229) {
                            break;
                        }
                        break;

                    case 2728: // Range in Catherby
                        if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), false, -1, -1)) {
                            break;
                        }
                        break;

                    case 2732: // Fire
                        if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), true, objectX, objectY)) {
                            break;
                        }
                        break;

                    case 36956: // Lumbridge furnace
                    case 11666: // Falador furnace
                        if (Smelting.wantToSmelt(player, player.getInventory().getItemInSlot(slot))) {
                            break;
                        } else if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
                            break;
                        }
                        break;

                    case 2783: // Anvil
                        if (Smithing.wantToSmithOnAnvil(player, player.getInventory().getItemInSlot(slot), new Location(objectX, objectY, player.getLocation().getZ()))) {
                            break;
                        }
                        break;

                    default:
                        player.getPackets().sendMessage("Nothing interesting happens.");
                        break;
                }
            }
        }
コード例 #13
0
ファイル: FightCave.cs プロジェクト: Krill156/SharpEMU
        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;
            }
        }
コード例 #14
0
ファイル: FightCave.cs プロジェクト: Krill156/SharpEMU
        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);
        }
コード例 #15
0
ファイル: BrokenBarrows.cs プロジェクト: Krill156/SharpEMU
 public static void talkToBob(Player p, Npc npc, int item, int option)
 {
     p.setEntityFocus(npc.getClientIndex());
     AreaEvent talkToBobAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1);
     talkToBobAreaEvent.setAction(() => {
         npc.setFaceLocation(p.getLocation());
         p.setFaceLocation(npc.getLocation());
         p.setEntityFocus(65535);
         if (option == 0) { // use item on bob
             if (item > 0) {
                 p.setTemporaryAttribute("bobsAxesBarrowItem", item);
                 showBobDialogue(p, 101);
             }
         } else if (option == 1) { // talk
             showBobDialogue(p, 107);
         } else if (option == 2) { // trade
             p.setShopSession(new ShopSession(p, 4));
         }
     });
     Server.registerCoordinateEvent(talkToBobAreaEvent);
 }
コード例 #16
0
ファイル: AreaVariables.cs プロジェクト: Krill156/SharpEMU
        /*
         * NOTE: Anything that goes in here and varies between HD and LD,
         * reset the variable in ActionSender.configureGameScreen
         */
        public void updateVariables(Player p)
        {
            int currentLevel = p.getLocation().wildernessLevel();
            if (currentLevel != -1)
            { //Is in wilderness.
                int lastWildLevel = (p.getTemporaryAttribute("wildLvl") == null) ? -1 : (int)p.getTemporaryAttribute("wildLvl");

                if (currentLevel != lastWildLevel)
                {
                    if (currentLevel > 0)
                    {
                        p.setTemporaryAttribute("wildLvl", currentLevel);
                        if (p.getTemporaryAttribute("inWild") == null)
                        {
                            p.getPackets().sendPlayerOption("Attack", 1, 1);
                            p.getPackets().sendOverlay(381);
                            p.setTemporaryAttribute("inWild", true);
                        }
                    }
                    else
                    {
                        if (p.getTemporaryAttribute("inWild") != null)
                        {
                            p.getPackets().sendPlayerOption("null", 1, 1);
                            p.getPackets().sendRemoveOverlay();
                            p.removeTemporaryAttribute("wildLvl");
                            p.removeTemporaryAttribute("inWild");
                        }
                    }
                }
            }
            if (Location.inMultiCombat(p.getLocation()))
            {
                if (p.getTemporaryAttribute("inMulti") == null)
                {
                    p.getPackets().displayMultiIcon();
                    p.setTemporaryAttribute("inMulti", true);
                }
            }
            else
            {
                if (p.getTemporaryAttribute("inMulti") != null)
                {
                    p.getPackets().removeMultiIcon();
                    p.removeTemporaryAttribute("inMulti");
                }
            }
            if (Location.atDuelArena(p.getLocation()))
            {
                if (p.getDuel() != null)
                {
                    if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
                    {
                        p.getPackets().sendPlayerOption("Fight", 1, 1);
                    }
                }
                if (p.getTemporaryAttribute("challengeUpdate") != null)
                {
                    p.getPackets().sendPlayerOption("Challenge", 1, 0);
                    p.removeTemporaryAttribute("challengeUpdate");
                }
                if (p.getTemporaryAttribute("atDuelArea") == null)
                {
                    p.getPackets().sendPlayerOption("Challenge", 1, 0);
                    p.getPackets().sendOverlay(638);
                    p.setTemporaryAttribute("atDuelArea", true);
                }
            }
            else
            {
                if (p.getTemporaryAttribute("atDuelArea") != null)
                {
                    p.getPackets().sendPlayerOption("null", 1, 0);
                    p.getPackets().sendRemoveOverlay();
                    p.removeTemporaryAttribute("atDuelArea");
                }
            }
            if (Location.atBarrows(p.getLocation()))
            {
                if (p.getTemporaryAttribute("atBarrows") == null)
                {
                    p.getPackets().sendOverlay(24);
                    p.getPackets().setMinimapStatus(2);
                    p.getPackets().sendConfig(452, 2652256); // doors
                    if (p.getTemporaryAttribute("betweenDoors") == null)
                    {
                        if (Barrows.betweenDoors(p))
                        {
                            p.setTemporaryAttribute("betweenDoors", true);
                            p.getPackets().sendConfig(1270, 1);
                        }
                    }
                    p.getPackets().modifyText("Kill Count: " + p.getBarrowKillCount(), 24, 0);
                    p.setTemporaryAttribute("atBarrows", true);
                    Barrows.prayerDrainEvent(p);
                    bool allBrothersKilled = true;
                    for (int i = 0; i < 6; i++)
                    {
                        if (!p.getBarrowBrothersKilled(i))
                        {
                            allBrothersKilled = false;
                        }
                    }
                    if (allBrothersKilled)
                    {
                        Barrows.startEarthQuake(p);
                    }
                }
            }
            else
            {
                if (p.getTemporaryAttribute("atBarrows") != null)
                {
                    bool allBrothersKilled = true;
                    for (int i = 0; i < 6; i++)
                    {
                        if (!p.getBarrowBrothersKilled(i))
                        {
                            allBrothersKilled = false;
                        }
                    }
                    if (allBrothersKilled)
                    {
                        for (int i = 0; i < 6; i++)
                        {
                            p.setBarrowBrothersKilled(i, false);

                            p.setBarrowTunnel(-1);
                            p.setBarrowKillCount(0);
                            p.getPackets().resetCamera();
                            p.removeTemporaryAttribute("lootedBarrowChest");
                        }
                        p.getPackets().resetCamera();
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("atBarrows");
                        p.removeTemporaryAttribute("barrowTunnel");
                        p.getPackets().setMinimapStatus(0);
                        Barrows.removeBrotherFromGame(p);
                    }
                }
                if (Location.atGodwars(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("atGodwars") == null)
                    {
                        p.getPackets().sendOverlay(601);
                        p.setTemporaryAttribute("atGodwars", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("atGodwars") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("atGodwars");
                    }
                }
                if (Location.atAgilityArena(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("atAgilityArena") == null)
                    {
                        p.getPackets().sendOverlay(5);
                        AgilityArena.updatePillarForPlayer(p);
                        p.setTemporaryAttribute("atAgilityArena", true);
                    }
                    if (p.getLocation().getZ() == 0)
                    {
                        p.removeTemporaryAttribute("atAgilityArena");
                        p.getPackets().sendRemoveOverlay();
                        p.setAgilityArenaStatus(0);
                        p.setTaggedLastAgilityPillar(false);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("atAgilityArena") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.setAgilityArenaStatus(0);
                        p.setTaggedLastAgilityPillar(false);
                        p.removeTemporaryAttribute("atAgilityArena");
                    }
                }
                /*
                 * We check the cantDoAnything variable to determine whether they're using the orb.
                 */
                if (Location.inFightPitsWaitingArea(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("waitingForFightPits") == null)
                    {
                        Server.getMinigames().getFightPits().addWaitingPlayer(p);
                        p.setTemporaryAttribute("waitingForFightPits", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("waitingForFightPits") != null && p.getTemporaryAttribute("cantDoAnything") == null)
                    {
                        Server.getMinigames().getFightPits().removeWaitingPlayer(p);
                        p.removeTemporaryAttribute("waitingForFightPits");
                    }
                }
                if (Location.inFightPits(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("cantDoAnything") == null)
                    {
                        if (p.getTemporaryAttribute("inFightPits") == null)
                        {
                            p.getPackets().sendPlayerOption("Attack", 1, 1);
                            Server.getMinigames().getFightPits().displayFightPitsInterface(p);
                            p.setTemporaryAttribute("inFightPits", true);
                        }
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("inFightPits") != null)
                    {
                        p.getPackets().sendPlayerOption("null", 1, 1);
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("inFightPits");
                    }
                }
                if (Location.onWaterbirthIsle(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("snowInterface") == null)
                    {
                        p.getPackets().sendOverlay(370);
                        p.setTemporaryAttribute("snowInterface", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("snowInterface") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("snowInterface");
                    }
                }
            }
        }
コード例 #17
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
 private static void sendProjectile(int index, Entity target, Player player)
 {
     foreach(Player p in Server.getPlayerList()) {
         if (p.getLocation().withinDistance(player.getLocation(), 60)) {
             if (index != 31 && index != 27) { // ice barrage + ice blitz
                 p.getPackets().sendProjectile(player.getLocation(), target.getLocation(), getStartingSpeed(index), AIR_GFX[index], 50, getProjectileHeight(index), getProjectileEndHeight(index), 100, target);
             } else {
                 p.getPackets().sendProjectile(player.getLocation(), target.getLocation(), getStartingSpeed(index), 368, 50, getProjectileHeight(index), getProjectileEndHeight(index), 100, target);
             }
         }
     }
 }
コード例 #18
0
ファイル: PlayerUpdate.cs プロジェクト: Krill156/SharpEMU
        /**
         * Update the specified player.
         * @param p
         */
        public static void update(Player player)
        {
            //Creates a list of new players in area. [This only happens once.. no rebuilding like all World 2 servers.]
            player.getLocalEnvironment().updatePlayersInArea();

            //Attempt to skip a pointless update if possible.
            //Any current users on screen got a update for me.
            bool hasAppearanceUpdate = player.getLocalEnvironment().getSeenPlayers().Exists(new Predicate<Player>(delegate(Player p) { return p.getUpdateFlags().hasAnyUpdate(); }));
            //No new pending players and no players pending to get removed from screen.
            bool hasAddRemoveUpdate = (player.getLocalEnvironment().getNewPlayers().Count > 0 || player.getLocalEnvironment().getRemovedPlayers().Count > 0);
            //no updates.. exit.

            if (!hasAppearanceUpdate && !hasAddRemoveUpdate && !player.getUpdateFlags().hasAnyUpdate() && !player.getUpdateFlags().didMapRegionChange() && player.getConnection().getPingCount() < 7) return;

            player.getConnection().resetPingCount();

            if(player.getUpdateFlags().didMapRegionChange())
                player.getPackets().sendMapRegion();

            PacketBuilder mainPacket = new PacketBuilder().setId(225).setSize(Packet.Size.VariableShort).initBitAccess();
            PacketBuilder updateBlock = new PacketBuilder().setSize(Packet.Size.Bare);

            if (player.getUpdateFlags().isTeleporting()) { //teleport
                mainPacket.addBits(1, 1);
                mainPacket.addBits(2, 3);
                mainPacket.addBits(7, player.getLocation().getLocalY(player.getUpdateFlags().getLastRegion())); //currentX
                mainPacket.addBits(1, 1);
                mainPacket.addBits(2, player.getLocation().getZ()); //heightLevel
                mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                mainPacket.addBits(7, player.getLocation().getLocalX(player.getUpdateFlags().getLastRegion())); //currentY
            } else {
                if (player.getSprites().getPrimarySprite() == -1) { //no movement
                    mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                    if (player.getUpdateFlags().isUpdateRequired())
                        mainPacket.addBits(2, 0);
                } else { //movement.
                    mainPacket.addBits(1, 1);
                    if (player.getSprites().getSecondarySprite() == -1) { //not running
                        mainPacket.addBits(2, 1);
                        mainPacket.addBits(3, player.getSprites().getPrimarySprite()); //walk
                        mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                    } else {
                        mainPacket.addBits(2, 2);
                        mainPacket.addBits(1, 1);
                        mainPacket.addBits(3, player.getSprites().getPrimarySprite()); //walk
                        mainPacket.addBits(3, player.getSprites().getSecondarySprite()); //run
                        mainPacket.addBits(1, player.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                    }
                }
            }
            if(player.getUpdateFlags().isUpdateRequired())
                appendUpdateBlock(player, updateBlock, false); //update my own updates.

            mainPacket.addBits(8, player.getLocalEnvironment().getSeenPlayers().Count); //All players I've seen already (not new players)

            //Send information of all the players in our own location.
            foreach (Player p in player.getLocalEnvironment().getSeenPlayers())
            {
                if (player.getLocalEnvironment().getRemovedPlayers().Contains(p)) {
                    mainPacket.addBits(1, 1); //update required.
                    mainPacket.addBits(2, 3); //delete player.
                    continue;
                } else if (p.getSprites().getPrimarySprite() == -1) {
                    if(p.getUpdateFlags().isUpdateRequired()) {
                        mainPacket.addBits(1, 1); //update required.
                        mainPacket.addBits(2, 0); //finish
                    } else {
                        mainPacket.addBits(1, 0); //no update required, either region changed or no movement change.
                    }
                } else if (p.getSprites().getPrimarySprite() != -1 && p.getSprites().getSecondarySprite() == -1) {
                    mainPacket.addBits(1, 1); //update required.
                    mainPacket.addBits(2, 1); //update just walk direction sprite
                    mainPacket.addBits(3, p.getSprites().getPrimarySprite());
                    mainPacket.addBits(1, p.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                } else if (p.getSprites().getPrimarySprite() != -1 && p.getSprites().getSecondarySprite() != -1) { //Bit 2 = 2, updates both sprites.
                    mainPacket.addBits(1, 1); //update required.
                    mainPacket.addBits(2, 2); //update both walk & run sprites.
                    mainPacket.addBits(1, 1);
                    mainPacket.addBits(3, p.getSprites().getPrimarySprite());
                    mainPacket.addBits(3, p.getSprites().getSecondarySprite());
                    mainPacket.addBits(1, p.getUpdateFlags().isUpdateRequired() ? 1 : 0);
                }
                if (p.getUpdateFlags().isUpdateRequired())
                    appendUpdateBlock(p, updateBlock, false);
             }

            //Send information of all the new players in our own location.
            foreach (Player p in player.getLocalEnvironment().getNewPlayers())
            {
                mainPacket.addBits(11, p.getIndex()); //playerId of new player.

                int yPos = p.getLocation().getY() - player.getLocation().getY();
                int xPos = p.getLocation().getX() - player.getLocation().getX();

                mainPacket.addBits(1, 1);
                mainPacket.addBits(5, xPos < 0 ? xPos + 32 : xPos);
                mainPacket.addBits(3, p.getWalkingQueue().getLastDirection());
                mainPacket.addBits(1, 1);
                mainPacket.addBits(5, yPos < 0 ? yPos + 32 : yPos);
                appendUpdateBlock(p, updateBlock, true); //force appearance update.
            }

            /**
             * Done with with all our updates.. fine to refine our environment lists.
             * Remove players who either moved away from our location or plain old disconnected.
             * Mix new players with old players into one playerlist.
             * Clear new players list, for more new players again
             */
            player.getLocalEnvironment().organizePlayers();

            if (updateBlock.getLength() > 0)
                mainPacket.addBits(11, 2047); //2047 max players in server,area.
            mainPacket.finishBitAccess();
            if (updateBlock.getLength() > 0)
                mainPacket.addBytes(updateBlock.toPacket().getData());
            if (player.getConnection() != null)
                player.getConnection().SendPacket(mainPacket.toPacket());
        }
コード例 #19
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
 private static bool canCastSpell(Player p, Entity target, int i, bool fakeNPC)
 {
     // fakeNPC is used to keep location when autocasting.
     if (fakeNPC) {
         return !p.isDead();
     }
     if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed()) {
         return false;
     }
     if (target is Npc) {
         if (((Npc) target).getHp() <= 0) {
             return false;
         }
         if (i == 47) {
             p.getPackets().sendMessage("You cannot cast Teleblock upon an NPC.");
             return false;
         }
     }
     if ((target is Player) && (p is Player)) {
         if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
         {
             if (!Server.getMinigames().getFightPits().hasGameStarted()) {
                 return false;
             }
             return true;
         }
         if (p.getDuel() != null) {
             if (((Player)target).getDuel() != null) {
                 if (p.getDuel().getPlayer2().Equals(((Player) target)) && ((Player) target).getDuel().getPlayer2().Equals(p)) {
                     if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC)) {
                         p.getPackets().sendMessage("Magical combat has been disabled in this duel!");
                         return false;
                     }
                     if (p.getDuel().getStatus() == 6 && ((Player) target).getDuel().getStatus() == 6) {
                         return true;
                     }
                 }
             }
             p.getPackets().sendMessage("That isn't your opponent.");
             return false;
         }
         if (i == 47) {
             if (((Player)target).getTemporaryAttribute("teleblocked") != null) {
                 p.getPackets().sendMessage("That player already has a teleportation block upon them.");
                 return false;
             }
         }
         if (!Location.inWilderness(target.getLocation())) {
             p.getPackets().sendMessage("That player isn't in the wilderness.");
             return false;
         }
         if (!Location.inWilderness(p.getLocation()))
         {
             p.getPackets().sendMessage("You aren't in the wilderness.");
             return false;
         }
         int killerWildLevel = p.getLocation().wildernessLevel();
         int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
         int killerCombatLevel = p.getSkills().getCombatLevel();
         int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
         int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
         int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
         int difference = (highest - lowest);
         if (difference > killerWildLevel || difference > targetWildLevel) {
             ((Player) p).getPackets().sendMessage("You must move deeper into the wilderness to attack that player.");
             return false;
         }
     }
     if (!Location.inMultiCombat(target.getLocation())) {
         if (p.getAttacker() != null && !p.getAttacker().Equals(target)) {
             p.getPackets().sendMessage("You are already in combat!");
             return false;
         }
         if (target.getAttacker() != null && !target.getAttacker().Equals(p)) {
             string type = target is Player ? "player" : "npc";
             p.getPackets().sendMessage("That " + type + " is already in combat.");
             return false;
         }
     }
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < SPELL_LEVEL[i]) {
         p.getPackets().sendMessage("You need a Magic level of " + SPELL_LEVEL[i] + " to cast that spell.");
         return false;
     }
     if (!hasRunes(p, RUNES[i], RUNE_AMOUNTS[i])) {
         p.getPackets().sendMessage("You do not have enough runes to cast that spell.");
         return false;
     }
     if (NEEDS_STAFF[i]) {
         if ((i != 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]) || (i == 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != 8841 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]))
         {
             p.getPackets().sendMessage("You need to wield " + STAFF_NAME[i] + " to cast this spell.");
             return false;
         }
     }
     if (i == 37) {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2412)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Saradomin to be able to cast Saradomin Strike.");
             return false;
         }
     }
     if (i == 38) {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2413)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Guthix to be able to cast Claws of Guthix.");
             return false;
         }
     }
     if (i == 39) {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2414)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Zamorak to be able to cast Flames of Zamorak.");
             return false;
         }
     }
     return true;
 }
コード例 #20
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
        private static bool canCastSpell2(Player p, Entity target, int i, bool fakeNPC)
        {
            // fakeNPC is used to keep location when autocasting.
            if (fakeNPC) {
                return !p.isDead();
            }
            if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed()) {
                return false;
            }
            if (target is Npc) {
                if (((Npc)target).getHp() <= 0)
                {
                    return false;
                }
            }
            if ((target is Player) && (p is Player)) {
                if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
                {
                    if (!Server.getMinigames().getFightPits().hasGameStarted()) {
                        return false;
                    }
                    return true;
                }
                if (p.getDuel() != null) {
                    if (((Player)target).getDuel() != null) {
                        if (p.getDuel().getPlayer2().Equals(((Player) target)) && ((Player) target).getDuel().getPlayer2().Equals(p)) {
                            if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC)) {
                                return false;
                            }
                            if (p.getDuel().getStatus() == 6 && ((Player) target).getDuel().getStatus() == 6) {
                                return true;
                            }
                        }
                    }
                    return false;
                }
                if (!Location.inWilderness(target.getLocation()) && !Location.inWilderness(p.getLocation()))
                    return false;

                int killerWildLevel = p.getLocation().wildernessLevel();
                int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
                int killerCombatLevel = p.getSkills().getCombatLevel();
                int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
                int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
                int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
                int difference = (highest - lowest);
                if (difference > killerWildLevel || difference > targetWildLevel) {
                    return false;
                }
            }
            return true;
        }
コード例 #21
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
 protected static bool hitsMulti(Player p, int index)
 {
     if (!Location.inMultiCombat(p.getLocation())) {
         return false;
     }
     switch(index) {
         case 20: return true; // Smoke burst.
         case 21: return true; // Shadow burst.
         case 22: return true; // Blood burst.
         case 23: return true; // Ice burst.
         case 28: return true; // Smoke barrage.
         case 29: return true; // Shadow barrage.
         case 30: return true; // Blood barrage.
         case 31: return true; // Ice barrage.
         case 49: return true; // Miasmic burst.
         case 51: return true; // Miasmic barrage.
     }
     return false;
 }
コード例 #22
0
ファイル: UnderGround.cs プロジェクト: Krill156/SharpEMU
 public void execute(Player player, string[] arguments)
 {
     player.teleport(new Location(player.getLocation().getX(), player.getLocation().getY() + 6400, 0));
 }
コード例 #23
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
 public static bool openCoffin(Player p, int objectId)
 {
     if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772) {
         return false;
     }
     int cryptIndex = getCryptIndex(p);
     if (cryptIndex == -1) {
         return false;
     }
     if (p.getBarrowBrothersKilled(cryptIndex)) {
         p.getPackets().sendMessage("You don't find anything.");
         return true;
     }
     if (p.getBarrowTunnel() == cryptIndex){
         p.getPackets().modifyText("You find a hidden tunnel, do you want to enter?", 210, 1);
         p.getPackets().sendChatboxInterface(210);
         p.setTemporaryAttribute("barrowTunnel", 1);
         return true;
     }
     foreach(Npc n in Server.getNpcList()) {
         if (n.getId() == BROTHER_ID[cryptIndex]) {
             if (n.getOwner().Equals(p)) {
                 p.getPackets().sendMessage("You don't find anything.");
                 return true;
             }
         }
     }
     Npc npc = new Npc(BROTHER_ID[cryptIndex]);
     npc.setLocation(p.getLocation());
     npc.setEntityFocus(p.getClientIndex());
     npc.setOwner(p);
     npc.setTarget(p);
     npc.setCombatTurns(npc.getAttackSpeed());
     Server.getNpcList().Add(npc);
     p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
     return true;
 }
コード例 #24
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 private void handlePickupItem(Player player, Packet packet)
 {
     int x = packet.readLEShort();
     int id  = packet.readUShort();
     int y  = packet.readLEShortA();
     Location l = new Location(x, y, player.getLocation().getZ());
     SkillHandler.resetAllSkills(player);
     if (x < 1000 || y < 1000 | id < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
         return;
     }
     player.getPackets().closeInterfaces();
     if(player.getLocation().Equals(l)) {
         Server.getGroundItems().pickupItem(player, id, player.getLocation());
         return;
     }
     CoordinateEvent pickupItemCoordinateEvent = new CoordinateEvent(player, l);
     pickupItemCoordinateEvent.setAction(() => {
         Server.getGroundItems().pickupItem(player, id, player.getLocation());
     });
     Server.registerCoordinateEvent(pickupItemCoordinateEvent);
 }
コード例 #25
0
ファイル: Barrows.cs プロジェクト: Krill156/SharpEMU
        public static void prayerDrainEvent(Player p)
        {
            Event prayerDrainEvent = new Event(5000 + misc.random(5000));
            prayerDrainEvent.setAction(() => {
                if (p.getTemporaryAttribute("atBarrows") == null) {
                    prayerDrainEvent.stop();
                    return;
                }
                int currentPrayer = p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                int maxLevel = p.getSkills().getMaxLevel(Skills.SKILL.PRAYER);
                int levelBy10 = currentPrayer - (maxLevel / 6);
                if (currentPrayer > 0) {
                    p.getSkills().setCurLevel(Skills.SKILL.PRAYER, levelBy10);
                    p.getPackets().sendSkillLevel(Skills.SKILL.PRAYER);
                }
                int[] array = p.getLocation().getZ() == 0 ? HEADS[1] : HEADS[0];
                int head = array[misc.random(array.Length - 1)];
                int slot = misc.random(5);
                if (slot == 0) {
                    slot=1;
                }
                p.getPackets().itemOnInterface(24, slot, 100,head);
                p.getPackets().animateInterface(2085, 24, slot);
                prayerDrainEvent.setTick(5000 + misc.random(15000));

                Event animateEvent = new Event(4000);
                animateEvent.setAction(() => {
                    p.getPackets().itemOnInterface(24, slot, 100, -1);
                    p.getPackets().animateInterface(-1, 24, slot);
                    animateEvent.stop();
                });
                Server.registerEvent(animateEvent);
            });
            Server.registerEvent(prayerDrainEvent);
        }
コード例 #26
0
ファイル: ItemInteract.cs プロジェクト: Krill156/SharpEMU
 private void handleDropItem(Player player, Packet packet)
 {
     int item = packet.readShortA();
     int slot = packet.readShortA();
     int interfaceId = packet.readLEShort();
     int childId = packet.readUShort();
     if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
         return;
     }
     SkillHandler.resetAllSkills(player);
     if (player.getInventory().getItemInSlot(slot) == item) {
         player.getPackets().closeInterfaces();
         if (ItemData.isPlayerBound(player.getInventory().getItemInSlot(slot))) {
             Item[] items = {new Item(player.getInventory().getItemInSlot(slot), 1)};
             //player.getPackets().sendItems(94, 0, 93, items);
             player.getPackets().modifyText("Are you sure you want to destroy this item?", 94, 3); // Title
             //player.getPackets().modifyText("Yes", 94, 4); // Yes
             //player.getPackets().modifyText("No", 94, 5); // No
             player.getPackets().modifyText("", 94, 10); // Line 1
             player.getPackets().modifyText("If you wish to get another Fire cape, you must", 94, 11); // Line 2
             player.getPackets().modifyText("complete the Fight cave minigame again.", 94, 12); // Line 3
             player.getPackets().modifyText("Fire Cape", 94, 13); // Item name
             player.getPackets().sendChatboxInterface(94);
             return;
         }
         int id = player.getInventory().getItemInSlot(slot);
         int amt = player.getInventory().getAmountInSlot(slot);
         GroundItem i = new GroundItem(id, amt, new Location(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()), player);
         if (player.getInventory().deleteItem(id, slot, amt)) {
             if (!Server.getGroundItems().addToStack(id, amt, player.getLocation(), player)) {
                 Server.getGroundItems().newEntityDrop(i);
             }
         }
     }
 }
コード例 #27
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
 public static void hitInMulti(Player p, Entity mainTarget, int index)
 {
     if (!Location.inMultiCombat(p.getLocation()) || !Location.inMultiCombat(mainTarget.getLocation())) {
         return;
     }
     else if (!hitsMulti(p, index)) {
         return;
     }
     Location l = mainTarget.getLocation();
     double totalDamage = 0;
     if (mainTarget is Npc) {
         foreach(Npc n in Server.getNpcList()) {
             if (n == null || n.Equals(mainTarget) || n.isDead() || n.isHidden() || n.isDestroyed()) {
                 continue;
             }
             if (n.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1)) {
                 if (!canCastSpell2(p, mainTarget, index, false)) {
                     continue;
                 }
                 if (n.isAutoRetaliating() && n.getTarget() == null) {
                     //n.getFollow().setFollowing(killer);
                     n.setEntityFocus(p.getClientIndex());
                     n.setCombatTurns(n.getAttackSpeed() / 2);
                     n.setTarget(p);
                 }
                 int damage = misc.random(misc.random(getSpellMaxHit(p, index))); //double randomize? uhh wtf?
                 int graphic = END_GFX[index];
                 if (damage == 0) {
                     graphic = 85;
                 }
                 if (damage > n.getHp()) {
                     damage = n.getHp();
                 }
                 if (damage > 0) {
                     bool frozen = freezeTarget(index, n);
                     if (!frozen && index == 31) {
                         graphic = 1677;
                     }
                 }
                 totalDamage += damage;
                 n.setAttacker(p);
                 n.setLastAttacked(Environment.TickCount);
                 n.setLastGraphics(new Graphics(graphic, 0, getGroundHeight(index, graphic)));
                 n.hit(damage);
                 if ((n.getCombatTurns() > 2 || n.getCombatTurns() < 0)) {
                     n.setLastAnimation(new Animation(n.getDefenceAnimation()));
                 }
                 addDamage(p, n, damage);
             }
         }
     } else {
         foreach(Player target in Server.getPlayerList()) {
             if (mainTarget == null || target.Equals(mainTarget) || target.isDead() || target.isHidden() || target.isDestroyed()) {
                 continue;
             }
             if (target.getLocation().inArea(l.getX() - 1, l.getY() - 1, l.getX() + 1, l.getY() + 1)) {
                 if (!canCastSpell2(p, mainTarget, index, false)) {
                     continue;
                 }
                 if (target.isAutoRetaliating() && target.getTarget() == null) {
                     //n.getFollow().setFollowing(killer);
                     target.setEntityFocus(p.getClientIndex());
                     target.setCombatTurns(target.getAttackSpeed() / 2);
                     target.setTarget(p);
                 }
                 int damage = misc.random(misc.random(getSpellMaxHit(p, index))); //double randomize? uhh wtf?
                 int graphic = END_GFX[index];
                 if (damage == 0) {
                     graphic = 85;
                 }
                 if (damage > target.getHp()) {
                     damage = target.getHp();
                 }
                 if (damage > 0) {
                     bool frozen = freezeTarget(index, target);
                     if (!frozen && index == 31) {
                         graphic = 1677;
                     }
                 }
                 totalDamage += damage;
                 target.setAttacker(p);
                 target.setLastAttacked(Environment.TickCount);
                 target.setLastGraphics(new Graphics(graphic, 0, getGroundHeight(index, graphic)));
                 target.hit(damage);
                 if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0)) {
                     target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                 }
                 addDamage(p, target, damage);
             }
         }
     }
     if (totalDamage > 0) {
         addMagicXp(p, null, totalDamage, index, false);
         if (index == 18 || index == 22 || index == 26 || index == 30) {
             p.heal((int) (totalDamage * 0.25));
         }
     }
 }
コード例 #28
0
ファイル: MagicCombat.cs プロジェクト: Krill156/SharpEMU
        public static void newMagicAttack(Player p, Entity target, int id, bool ancients)
        {
            int index = getSpellIndex(p, id, ancients);
            bool autoCasting = p.getTemporaryAttribute("autoCasting") != null;
            bool fakeNPC = target != null && target is Npc && ((Npc)target).getId() == 0;
            Entity lastAutocastEntity = null;
            bool frozen = false;
            if (index == -1) {
                return;
            }
            if (p.getTarget() == null) {
                if (autoCasting) {
                    if (Location.inMultiCombat(p.getLocation())) {
                        lastAutocastEntity = (Entity) p.getTemporaryAttribute("autocastEntity") == null ? null : (Entity) p.getTemporaryAttribute("autocastEntity");
                        if (lastAutocastEntity == null || lastAutocastEntity is Player) {
                            p.removeTemporaryAttribute("autoCasting");
                            Combat.resetCombat(p, 1);
                            return;
                        }
                        if (hitsMulti(p, index)) {
                            Location location = (Location)p.getTemporaryAttribute("autocastLocation");
                            Entity newTarget = new Npc(0);
                            newTarget.setLocation(location);
                            p.setTarget(newTarget);
                            newMagicAttack(p, newTarget, id, ancients);
                            return;
                        }
                    } else {
                        p.removeTemporaryAttribute("autoCasting");
                        Combat.resetCombat(p, 1);
                        return;
                    }
                } else {
                    p.removeTemporaryAttribute("autoCasting");
                    Combat.resetCombat(p, 1);
                    return;
                }
            } else {
                if (!canCastSpell(p, target, index, fakeNPC)) {
                    p.removeTemporaryAttribute("autoCasting");
                    Combat.resetCombat(p, 1);
                    return;
                }
            }
            int distance = 8;
            if (target is Player) {
                if (((Player)target).getSprites().getPrimarySprite() != -1) {
                    distance = 8;
                }
            }
            if (!fakeNPC) { // we're actually attacking a real npc/player
                if (!p.getLocation().withinDistance(target.getLocation(), distance)) {
                    p.getFollow().setFollowing(target);

                    Event attemptMagicAttackEvent = new Event(500);
                    int attemptMagicAttackCounter = 0;
                    attemptMagicAttackEvent.setAction(() => {
                        if (p.getLocation().withinDistance(target.getLocation(), distance) && p.getTarget() != null) {
                            attemptMagicAttackEvent.stop();
                            newMagicAttack(p, target, id, ancients);
                            return;
                        }
                        attemptMagicAttackCounter++;
                        if (attemptMagicAttackCounter >= 12)
                        {
                            attemptMagicAttackEvent.stop();
                        }
                    });
                    Server.registerEvent(attemptMagicAttackEvent);
                    return;
                }
            }
            int timeSinceLastCast = autoCasting ? 3500 : 2000;
            if (Environment.TickCount - p.getLastMagicAttack() < timeSinceLastCast) {
                p.getWalkingQueue().resetWalkingQueue();
                //return;
            }
            int time = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1550 : 600;
            if (Environment.TickCount - p.getLastAttack() <  time) {
                int delay = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1350 : 800;
                Event attemptMagicAttackEvent = new Event(500);
                attemptMagicAttackEvent.setAction(() => {
                    if (Environment.TickCount - p.getLastAttack() > delay) {
                        attemptMagicAttackEvent.stop();
                        newMagicAttack(p, target, id, ancients);
                    }
                });
                Server.registerEvent(attemptMagicAttackEvent);

                p.getWalkingQueue().resetWalkingQueue();
                p.getPackets().clearMapFlag();
                p.setLastCombatType(Combat.CombatType.MAGE);
                return;
            }
            if (fakeNPC && !monsterInArea(p, target)) {
                p.removeTemporaryAttribute("autoCasting");
                Combat.resetCombat(p, 1);
                return;
            }
            int endGfx = END_GFX[index];
            double damage = misc.random(CombatFormula.getMagicHit(p, target, getSpellMaxHit(p, index)));
            bool mp = false;
            bool magicProtect = mp;
            if (target is Player) {
                mp = ((Player) target).getPrayers().getHeadIcon() == PrayerData.MAGIC;
            }
            if (magicProtect) {
                damage *= 0.60;
            }
            if (p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) == 8841) {
                damage *= 1.10; // void mace 10% hit increase.
            }
            if (damage == 0 && index != 41 && index != 42 && index != 43 && index != 44 && index != 45 && index != 46 && index != 47) {
                endGfx = 85;
            }
            if (!deleteRunes(p, RUNES[index], RUNE_AMOUNTS[index])) {
                p.setTarget(null);
                return;
            }
            p.getFollow().setFollowing(null);
            p.getWalkingQueue().resetWalkingQueue();
            p.getPackets().clearMapFlag();
            p.setFaceLocation(target.getLocation());
            if (HANDS_GFX[index] != -1) {
                p.setLastGraphics(new Graphics(HANDS_GFX[index], 0 , getStartingGraphicHeight(index)));
            }
            p.setLastAnimation(new Animation(SPELL_ANIM[index]));
            p.getPackets().closeInterfaces();
            if (target is Player) {
                ((Player) target).getPackets().closeInterfaces();
            }
            target.setAttacker(p);
            p.setTarget(target);
            target.setLastAttacked(Environment.TickCount);
            p.setLastAttack(Environment.TickCount);
            p.setLastMagicAttack(Environment.TickCount);
            p.setCombatTurns(p.getAttackSpeed());
            Combat.setSkull(p, target);
            if (damage > 0) {
                frozen = freezeTarget(index, target);
                if (!frozen && index == 31) {
                    endGfx = 1677;
                }
            }
            if (AIR_GFX[index] != -1 || ((index == 31 || index == 27) && target is Player && ((Player)target).getWalkingQueue().isRunning())) {
                sendProjectile(index, target, p);
            }
            if (damage > target.getHp()) {
                damage = target.getHp();
            }
            if (index == 47 && misc.random(2) == 0) {
                endGfx = 85;
            }
            Combat.checkIfWillDie(target, damage);
            Event doMagicAttackEvent = new Event(getSpellHitDelay(index));
            doMagicAttackEvent.setAction(() => {
                doMagicAttackEvent.stop();
                if (p == null || p.isDead() || !fakeNPC && (target.isDead() || target.isHidden() || target.isDestroyed())) {
                    return;
                }
                if (target.isAutoRetaliating() && target.getTarget() == null && damage > 0) {
                    if (target is Npc) {
                    } else {
                        if (((Player) target).getTemporaryAttribute("autoCastSpell") != null) {
                            int autoCastSpell = (int)((Player) target).getTemporaryAttribute("autoCastSpell");
                            ((Player) target).setTemporaryAttribute("autoCasting", true);
                            target.setTarget(p);
                            MagicCombat.newMagicAttack((Player) target, p, autoCastSpell, ((Player) target).getTemporaryAttribute("autoCastAncients") != null);
                        }
                    }
                    target.getFollow().setFollowing(p);
                    target.setEntityFocus(p.getClientIndex());
                    if ((target.getCombatTurns() <= (target.getAttackSpeed() / 2) || target.getCombatTurns() >= (target.getAttackSpeed()))) {
                        target.setCombatTurns(target.getAttackSpeed() / 2);
                    }
                    target.setTarget(p);
                    if (target is Player) {
                        ((Player) target).getWalkingQueue().resetWalkingQueue();
                        ((Player) target).getPackets().clearMapFlag();
                    }
                }
                addMagicXp(p, target, damage, index, true);
                target.setLastGraphics(new Graphics(endGfx, 0, getGroundHeight(index, endGfx)));
                if (index == 47 && endGfx != 85) { // teleblock
                    if (target is Player) {
                        teleblockPlayer(p, (Player)target);
                    }
                }
                if (damage != 0) {
                    Combat.checkRecoil(p, target, damage);
                    Combat.checkSmite(p, target, damage);
                    Combat.checkVengeance(p, target, damage);
                    hitInMulti(p, target, index);
                    applyMiasmicEffects(p, target, index);
                    if ((target.getCombatTurns() > 2 || target.getCombatTurns() < 0) && !target.isDead()) {
                        target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                    }
                    if (index != 27) {
                        target.hit((int)damage);
                        if (index == 18 || index == 22 || index == 26 || index == 30) {
                            p.heal(Convert.ToInt32(damage / 4));
                        }
                    } else if (index == 27){
                        Event doHitEvent = new Event(1000);
                        doHitEvent.setAction(() => {
                                doHitEvent.stop();
                                target.hit((int)damage);
                        });
                        Server.registerEvent(doHitEvent);
                    }
                }
            });
            Server.registerEvent(doMagicAttackEvent);
            if (p.getTemporaryAttribute("autoCasting") != null) {
                if (p.getTemporaryAttribute("autoCastSpell") != null) {
                    if (id != (int)p.getTemporaryAttribute("autoCastSpell")) {
                        p.setTarget(null);
                        return;
                    }
                }
                if (!fakeNPC) {
                    p.setTemporaryAttribute("autocastLocation", target.getLocation());
                    p.setTemporaryAttribute("autocastEntity", target);
                }
                Event autoCastSpellEvent = new Event(3500);
                autoCastSpellEvent.setAction(() => {
                    autoCastSpellEvent.stop();
                    if (p.getTemporaryAttribute("autoCasting") != null && p.getTemporaryAttribute("autoCastSpell") != null) {
                        int autoCastSpell = (int)p.getTemporaryAttribute("autoCastSpell");
                        MagicCombat.newMagicAttack(p, p.getTarget(), autoCastSpell, p.getTemporaryAttribute("autoCastAncients") != null);
                    }
                });
                Server.registerEvent(autoCastSpellEvent);
            } else {
                p.setTarget(null);
            }
        }
コード例 #29
0
ファイル: GroundItem.cs プロジェクト: Krill156/SharpEMU
 public static GroundItem newPlayerDroppedItem(Player player, Item item)
 {
     return new GroundItem(item.getItemId(), item.getItemAmount(), player.getLocation(), player);
 }