Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players;
- import java.util.ArrayList;
- import java.util.LinkedList;
- import java.util.List;
- import server.Config;
- import server.World;
- import server.model.items.Item;
- import server.model.minigames.BarrowsData;
- import server.model.npcs.NPC;
- import server.model.players.combat.CombatConstants;
- import server.region.Region;
- import server.World;
- import server.tickable.Tickable;
- import server.tickable.impl.PoisonDrainTick;
- import server.util.ISAACRandomGen;
- import server.util.Misc;
- import server.util.Stream;
- import server.world.Location;
- public abstract class Player {
- public int x1 = -1, y1 = -1, x2 = -1, y2 = -1, speed1 = -1, speed2 = -1, direction = -1;
- public boolean stopPlayerPacket;
- public boolean inSetMode = false;
- public int chosenSkill = -1;
- public int kills = 0, deaths = 0, killStreak = 0, maxKillStreak = 0;
- public int poisonDamage = 0;
- public int drainPoint;
- public int currentInterface = -1;
- public int travel;
- public int dfsDelay;
- public boolean playerStun = false, newPlayer = false;
- public boolean recentlyUsedSpec = false;
- public long lastDagChange = -1, lastRunRecovery;
- public int rfdRound;
- public boolean rfdSpawned = false;
- public boolean rfdOption = false;
- public boolean horrorOption = false;
- public boolean casketOption = false;
- public boolean solEffect;
- public double solDelay = 0;
- public int hitType;
- public int soak = 0;
- public String loginMessage = "";
- public int npcWave = 1;
- public boolean crit = false;
- public boolean hasBankPIN = false;
- public int hasDoneCaves = 0;
- public int duelTarget;
- public boolean fcFlag = false, dfsActive;
- public boolean hasBoosted = false;
- public boolean protectItem = false;
- public boolean demoteUser = false, promoteUser = false, kickUser = false;
- public String bankPin = "";
- public int attempts = 3;
- public int newDamage;
- public double absorbMagic, absorbMelee, absorbRanged;
- public double percentage;
- public boolean canUseKorasi = false;
- public boolean startingOut = false;
- public boolean setPin = false;
- public boolean inCyclops;
- public boolean spawned;
- public boolean hasOverloadBoost;
- public int hitOwner = 1;
- public boolean forceMovementUpdate;
- public long lastFire;
- public boolean teleporting = false;
- public int telePorting = 0;
- public int teleportDelay = -1;
- public int lsp = 0;
- public int teleToX = 0;
- public int teleToY = 0;
- public int newHeight = 0;
- public long nloadDelay;
- public int[][] playerSkillProp = new int[20][15];
- public boolean[] playerSkilling = new boolean[20];
- public boolean beserkerEffect = false;
- public double crossbowDamage;
- public int cannonTimer = 0;
- public boolean specGfx = false;
- public boolean multiAttacking, rangeEndGFXHeight, playerFletch, playerIsFletching, playerIsMining, playerIsFiremaking, playerIsFishing, playerIsCooking, playerIsWoodcutting;
- public boolean ignoreDefence, usingBow, usingArrows, usingOtherRangeWeapons, usingCross, magicDef, spellSwap, hasBankPin, recoverysSet;
- public int rangeEndGFX, boltDamage, teleotherType, playerTradeWealth, doAmount, woodcuttingTree, stageT, dfsCharge, recoilHits, playerDialogue;
- public ArrayList<String> lastKilledPlayers = new ArrayList<String>();
- public boolean TunnelEntrance = false;
- public int Arma, Zammy, Sara;
- public int Band;
- public boolean xpLock;
- public boolean kamfreenaDone;
- public int xamount;
- public int usedOnObjectID, usedOnobjectX, usedOnobjectY;
- public boolean
- stopPlayerSkill,
- herbloreI = false,
- secondHerb = false;
- public int
- herbAmount,
- doingHerb,
- newHerb,
- newXp,
- newItem;
- /** Curse variables */
- public int soulSplitDelay = 0,
- leechAttackDelay = 0,
- leechRangeDelay = 0,
- leechMagicDelay = 0,
- leechDefenceDelay = 0,
- leechStrengthDelay = 0,
- leechSpecialDelay = 0,
- leechAttackTimer = 0,
- leechRangeTimer = 0;
- public int atkCount = 0;
- public boolean turmoilBoolean, berserkerBoolean, soulsplitBoolean, protectSummon, protectMissiles, protectMelee, wrathBoolean, protectMage;
- public boolean specleech = false;
- public boolean attackleech = false;
- public boolean rangedleech = false;
- public boolean magicleech = false;
- public boolean defenceleech = false;
- public boolean strengthleech = false;
- public int WillKeepAmt1,WillKeepAmt2,WillKeepAmt3,WillKeepAmt4,WillKeepItem1,WillKeepItem2,WillKeepItem3,WillKeepItem4,WillKeepItem1Slot,WillKeepItem2Slot,WillKeepItem3Slot,WillKeepItem4Slot,EquipStatus;
- public boolean isDoingSkillcapeAnim = false;
- public long lastCast = 0;
- public ArrayList <String>killedPlayers = new ArrayList<String> ();
- public ArrayList <Integer>attackedPlayers = new ArrayList<Integer> ();
- public int[] clawHit = new int[4];
- public boolean
- usingClaws,
- disableWalking = false,
- teleportFlag = false,
- pNpc = false,
- autoRetaliate = false,
- initialized = false,
- disconnected = false,
- ruleAgreeButton = false,
- RebuildNPCList = false,
- isActive = false,
- isKicked = false,
- isSkulled = false,
- friendUpdate = false,
- hasMultiSign = false,
- inAclan = false,
- saveCharacter = false,
- mouseButton = false,
- splitChat = false,
- chatEffects = true,
- acceptAid = false,
- nextDialogue = false,
- autocasting = false,
- usedSpecial = false,
- mageFollow = false,
- dbowSpec = false,
- craftingLeather = false,
- properLogout = false,
- secDbow = false,
- ssSpec = false,
- vengOn = false,
- addStarter = false,
- accountFlagged = false,
- msbSpec = false,
- newCmb = false,
- runOption,
- isBanking = false
- ;
- public boolean isDoingComp = false;
- public int playerTitle;
- public boolean isRunning() {
- if (stopPlayerPacket) {
- return false;
- }
- return isNewWalkCmdIsRunning() || (runOption && isMoving);
- }
- public boolean handcannon = false;
- public int
- runEnergy = 100,
- barrageCount = 0,
- CSLS = 0,
- pNpcId = -1,
- recoil = 0,
- headIconHints,
- pure,
- saveDelay,
- altarPrayed = 0,
- playerKilled,
- pkPoints,
- wcLevelReq,
- totalPlayerDamageDealt,
- killedBy,
- lastChatId = 1,
- privateChat,
- friendSlot = 0,
- dialogueId,
- fishingLevelReq,
- processPackets = 0,
- newLocation,
- lastNpcAttacked = 0,
- specEffect,
- specBarId,
- processTimer,
- attackLevelReq,
- fletchingLevelReq,
- Donatorreq,
- defenceLevelReq,
- strengthLevelReq,
- rangeLevelReq,
- magicLevelReq,
- followId,
- skullTimer,
- nextChat = 0,
- talkingNpc = -1,
- dialogueAction = 0,
- autocastId,
- followDistance,
- followId2,
- pcPoints,
- isDonator = 0,
- desertTreasure = 0,
- lastArrowUsed = -1,
- clanId = -1,
- pcDamage = 0,
- xInterfaceId = 0,
- xRemoveId = 0,
- xRemoveSlot = 0,
- waveId,
- frozenBy = 0,
- teleAction = 0,
- bonusAttack = 0,
- newCombat = 0;
- public String currentTime, date;
- public String clanName, properName;
- public int[] itemKeptId = new int [4];
- public int[] pouches = new int[4];
- public boolean[] invSlot = new boolean[28], equipSlot = new boolean[14];
- public long friends[] = new long[200];
- public long lastButton;
- public double specDamage, specAccuracy, specAmount;
- public double prayerPoint = 1.0;
- public int teleGrabItem, teleGrabX, teleGrabY, duelCount, underAttackBy, underAttackBy2, wildLevel, respawnTimer, saveTimer = 0, teleBlockLength, poisonDelay;
- public long lastPlayerMove,lastPoison,lastPoisonSip,poisonImmune,lastSpear,lastProtItem, lastVeng,lastYell,teleGrabDelay, protMageDelay, protMeleeDelay, protRangeDelay, lastAction, lastThieve,lastLockPick,lastRunDrain, alchDelay, specDelay = System.currentTimeMillis(), duelDelay, teleBlockDelay, godSpellDelay, singleCombatDelay, singleCombatDelay2, reduceStat, restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay;
- public boolean canChangeAppearance = false;
- public boolean mageAllowed;
- public long SpecialDelay = 0;
- public byte poisonMask = 0;
- public boolean withinInteractionDistance(int x, int y, int z) {
- if (heightLevel != z)
- return false;
- Client c = (Client)this;
- int deltaX = x - c.getX(), deltaY = y - c.getY();
- return deltaX <= 4 && deltaX >= -4 && deltaY <= 4 && deltaY >= -4;
- }
- public boolean isAutoButton(int button) {
- for (int j = 0; j < CombatConstants.autocastIds.length; j += 2) {
- if (CombatConstants.autocastIds[j] == button)
- return true;
- }
- return false;
- }
- public boolean doingEmote() {
- return (this.animationRequest != -1);
- }
- public boolean fullVerac() {
- return playerEquipment[playerHat] == 4753 && playerEquipment[playerLegs] == 4759 && playerEquipment[playerChest] == 4757 && playerEquipment[playerWeapon] == 4755;
- }
- //public String spellName = "Select Spell";
- public void assignAutocast(int button) {
- for (int j = 0; j < CombatConstants.autocastIds.length; j++) {
- if (CombatConstants.autocastIds[j] == button) {
- Client c = (Client) PlayerHandler.players[this.playerId];
- autocasting = true;
- autocastId = CombatConstants.autocastIds[j+1];
- c.getPA().sendFrame36(108, 1);
- c.setSidebarInterface(0, 328);
- c = null;
- break;
- }
- }
- }
- public boolean[] killedBrother = new boolean[7];
- public boolean[] spawnedBrother = new boolean[7];
- public int barrowsKill;
- public int hiddenBrother;
- public boolean inBarrows() {
- return (absX >= BarrowsData.BARROW_CAVE[0] && absX <= BarrowsData.BARROW_CAVE[2] & absY >= BarrowsData.BARROW_CAVE[1] && absY <= BarrowsData.BARROW_CAVE[3]);
- }
- public boolean fullVoidRange() {
- return playerEquipment[playerHat] == 11664 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
- }
- public boolean fullVoidMage() {
- return playerEquipment[playerHat] == 11663 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
- }
- public boolean fullVoidMelee() {
- return playerEquipment[playerHat] == 11665 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
- }
- public int reduceSpellId;
- public long[] reduceSpellDelay = new long[6];
- public boolean[] canUseReducingSpell = {true, true, true, true, true, true};
- public int slayerTask,taskAmount;
- public int prayerId = -1;
- public int headIcon = -1;
- public int bountyIcon = 0;
- public long stopPrayerDelay, prayerDelay;
- public boolean usingPrayer;
- public boolean[] prayerActive = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
- /* Curse Prayers */
- public boolean[] curseActive = {
- false,false,false,false,false,
- false,false,false,false,false,
- false,false,false,false,false,
- false,false,false,false,false
- };
- /*End of curse prayers*/
- public int duelTimer, duelTeleX, duelTeleY, duelSlot, duelSpaceReq, duelOption, duelingWith, duelStatus;
- public int headIconPk = -1, headIconhint;
- public int headIconPray = 0;
- public boolean duelRequested;
- public boolean[] duelRule = new boolean[22];
- public boolean doubleHit, usingSpecial, npcDroppingItems, usingRangeWeapon, usingMagic, castingMagic;
- public int specMaxHitIncrease, freezeDelay, freezeTimer = -6, killerId, playerIndex, oldPlayerIndex, lastWeaponUsed, projectileStage, crystalBowArrowCount, playerMagicBook, teleGfx, teleEndAnimation, teleHeight, teleX, teleY, rangeItemUsed, killingNpcIndex, totalDamageDealt, oldNpcIndex, fightMode, attackTimer, npcIndex,npcClickIndex, npcType, castingSpellId, oldSpellId, spellId, hitDelay;
- public boolean magicFailed, oldMagicFailed;
- public int bowSpecShot, clickNpcType, clickObjectType, objectId, objectX, objectY, objectXOffset, objectYOffset, objectDistance;
- public int pItemX, pItemY, pItemId;
- public boolean isMoving, walkingToItem;
- public boolean isShopping, updateShop;
- public int myShopId;
- public int tradeStatus, tradeWith;
- public boolean forcedChatUpdateRequired, inDuel, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade;
- public int attackAnim, animationRequest = -1,animationWaitCycles;
- public int[] playerBonus = new int[12];
- public boolean takeAsNote;
- public int combatLevel;
- public boolean saveFile = false;
- public int playerAppearance[] = new int[13];
- public int apset;
- public int actionID;
- public int wearItemTimer, wearId, wearSlot, interfaceId;
- public int XremoveSlot, XinterfaceID, XremoveID, Xamount;
- public boolean usingGlory = false;
- public int smeltType; //1 = bronze, 2 = iron, 3 = steel, 4 = gold, 5 = mith, 6 = addy, 7 = rune
- public int smeltAmount;
- public int smeltTimer = 0;
- public boolean smeltInterface;
- public boolean antiFirePot = false;
- /**
- * SouthWest, NorthEast, SouthWest, NorthEast
- */
- public boolean inGWD() {
- if (absX > 2820 && absX < 2955 && absY > 5250 && absY < 5370) {
- return true;
- }
- return false;
- }
- public boolean inArea(int x, int y, int x1, int y1) {
- if (absX > x && absX < x1 && absY < y && absY > y1) {
- return true;
- }
- return false;
- }
- public boolean inDungeoneering() {
- return false;
- }
- public boolean inPits() {
- return inArea(2370, 2430, 5122, 5168);
- }
- public boolean inWild() {
- if (absX > 2941 && absX < 3392 && absY > 3524 && absY < 3966 ||
- absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366){
- return true;
- }
- return false;
- }
- public boolean isInEdge() {
- if(absX > 3084 && absX < 3111 && absY > 3483 && absY < 3509) {
- return true;
- }
- return false;
- }
- public boolean inPitsWait() {
- return getX() >= 2393 && getX() <= 2405 && getY() >= 5169 && getY() <= 5175;
- }
- public boolean safeZone() {
- if(absX > 2608 && absX < 2617 && absY > 3087 && absY < 3098 || absX > 2612 && absX < 2622 && absY > 3330 && absY < 3335 || absX > 2648 && absX < 2658 && absY > 3279 && absY < 3287) {
- return true;
- }
- return false;
- }
- public boolean arenas() {
- if(absX > 3331 && absX < 3391 && absY > 3242 && absY < 3260) {
- return true;
- }
- return false;
- }
- public boolean inDuelArena() {
- if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
- (absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
- return true;
- }
- return false;
- }
- public boolean inMulti() {
- if((absX >= 3136 && absX <= 3327 && absY >= 3519 && absY <= 3607) ||
- (absX >= 3210 && absX <= 3339 && absY >= 9333 && absY <= 9424) ||
- (absX >= 2607 && absX <= 2644 && absY >= 3296 && absY <= 3332) ||
- (absX >= 2949 && absX <= 3001 && absY >= 3370 && absY <= 3392) ||
- (absX >= 3250 && absX <= 3342 && absY >= 9800 && absY <= 9870) ||
- (absX >= 3190 && absX <= 3327 && absY >= 3648 && absY <= 3839) ||
- (absX >= 3200 && absX <= 3390 && absY >= 3840 && absY <= 3967) ||
- (absX >= 2992 && absX <= 3007 && absY >= 3912 && absY <= 3967) ||
- (absX >= 2946 && absX <= 2959 && absY >= 3816 && absY <= 3831) ||
- (absX >= 3008 && absX <= 3199 && absY >= 3856 && absY <= 3903) ||
- (absX >= 3008 && absX <= 3071 && absY >= 3600 && absY <= 3711) ||
- (absX >= 3072 && absX <= 3327 && absY >= 3608 && absY <= 3647) ||
- (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619) ||
- (absX >= 2371 && absX <= 2422 && absY >= 5062 && absY <= 5117) ||
- (absX >= 2896 && absX <= 2927 && absY >= 3595 && absY <= 3630) ||
- (absX >= 2820 && absX <= 2955 && absY >= 5250 && absY <= 5370) ||
- (absX >= 2892 && absX <= 2932 && absY >= 4435 && absY <= 4464) ||
- (absX >= 3465 && absX <= 3508 && absY >= 9480 && absY <= 9518) ||
- (absX >= 3080 && absX <= 3140 && absY >= 9800 && absY <= 9860) ||
- (absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <= 4711)) {
- return true;
- }
- return false;
- }
- public boolean inFightCaves()
- {
- return (absX >= 2360 && absX <= 2445 && absY >= 5045 && absY <= 5125);
- }
- public String connectedFrom="";
- public String globalMessage="";
- public abstract void initialize();
- public abstract void update();
- public int playerId = -1;
- public String playerName = null;
- public String playerName2 = null;
- public String playerPass = null;
- public int playerRights;
- public int playerItems[] = new int[28];
- public int playerItemsN[] = new int[28];
- public int bankItems[] = new int[Config.BANK_SIZE];
- public int bankItemsN[] = new int[Config.BANK_SIZE];
- public boolean bankNotes = false;
- public int playerStandIndex = 0x328;
- public int playerTurnIndex = 0x337;
- public int playerWalkIndex = 0x333;
- public int playerTurn180Index = 0x334;
- public int playerTurn90CWIndex = 0x335;
- public int playerTurn90CCWIndex = 0x336;
- public int playerRunIndex = 824;
- public int playerHat=0;
- public int playerCape=1;
- public int playerAmulet=2;
- public int playerWeapon=3;
- public int playerChest=4;
- public int playerShield=5;
- public int playerLegs=7;
- public int playerHands=9;
- public int playerFeet=10;
- public int playerRing=12;
- public int playerArrows=13;
- public int playerAttack = 0;
- public int playerDefence = 1;
- public int playerStrength = 2;
- public int playerHitpoints = 3;
- public int playerRanged = 4;
- public int playerPrayer = 5;
- public int playerMagic = 6;
- public int playerCooking = 7;
- public int playerWoodcutting = 8;
- public int playerFletching = 9;
- public int playerFishing = 10;
- public int playerFiremaking = 11;
- public int playerCrafting = 12;
- public int playerSmithing = 13;
- public int playerMining = 14;
- public int playerHerblore = 15;
- public int playerAgility = 16;
- public int playerThieving = 17;
- public int playerSlayer = 18;
- public int playerFarming = 19;
- public int playerRunecrafting = 20;
- public int playerHunter = 21;
- public int[] playerEquipment = new int[14];
- public int[] playerEquipmentN = new int[14];
- public int[] playerLevel = new int[25];
- public int[] playerXP = new int[25];
- public void updateshop(int i){
- Client p = (Client) PlayerHandler.players[playerId];
- p.getShops().resetShop(i);
- }
- public void println_debug(String str) {
- System.out.println("[player-"+playerId+"]: "+str);
- }
- public void println(String str) {
- System.out.println("[player-"+playerId+"]: "+str);
- }
- public Player(int _playerId) {
- playerId = _playerId;
- playerRights = 0;
- for (int i=0; i<playerItems.length; i++) {
- playerItems[i] = 0;
- }
- for (int i=0; i<playerItemsN.length; i++) {
- playerItemsN[i] = 0;
- }
- for (int i=0; i<playerLevel.length; i++) {
- if (i == 3) {
- playerLevel[i] = 10;
- } else {
- playerLevel[i] = 1;
- }
- }
- for (int i=0; i<playerXP.length; i++) {
- if (i == 3) {
- playerXP[i] = 1300;
- } else {
- playerXP[i] = 0;
- }
- }
- for (int i=0; i < Config.BANK_SIZE; i++) {
- bankItems[i] = 0;
- }
- for (int i=0; i < Config.BANK_SIZE; i++) {
- bankItemsN[i] = 0;
- }
- playerAppearance[0] = 0; // gender
- playerAppearance[1] = 7; // head
- playerAppearance[2] = 25;// Torso
- playerAppearance[3] = 29; // arms
- playerAppearance[4] = 35; // hands
- playerAppearance[5] = 39; // legs
- playerAppearance[6] = 44; // feet
- playerAppearance[7] = 14; // beard
- playerAppearance[8] = 7; // hair colour
- playerAppearance[9] = 8; // torso colour
- playerAppearance[10] = 9; // legs colour
- playerAppearance[11] = 5; // feet colour
- playerAppearance[12] = 0; // skin colour
- apset = 0;
- actionID = 0;
- playerEquipment[playerHat]=-1;
- playerEquipment[playerCape]=-1;
- playerEquipment[playerAmulet]=-1;
- playerEquipment[playerChest]=-1;
- playerEquipment[playerShield]=-1;
- playerEquipment[playerLegs]=-1;
- playerEquipment[playerHands]=-1;
- playerEquipment[playerFeet]=-1;
- playerEquipment[playerRing]=-1;
- playerEquipment[playerArrows]=-1;
- playerEquipment[playerWeapon]=-1;
- heightLevel = 0;
- teleportToX = Config.START_LOCATION_X;
- teleportToY = Config.START_LOCATION_Y;
- absX = absY = -1;
- mapRegionX = mapRegionY = -1;
- currentX = currentY = 0;
- resetWalkingQueue();
- }
- public void destruct() {
- getLocalPlayers().clear();
- getLocalNPCs().clear();
- absX = absY = -1;
- mapRegionX = mapRegionY = -1;
- currentX = currentY = 0;
- resetWalkingQueue();
- }
- public static final int maxPlayerListSize = 500;
- public Player playerList[] = new Player[maxPlayerListSize];
- public int playerListSize = 0;
- public byte playerInListBitmap[] = new byte[(maxPlayerListSize+7) >> 3];
- public static final int maxNPCListSize = 600;
- public NPC npcList[] = new NPC[maxNPCListSize];
- public int npcListSize = 0;
- public byte npcInListBitmap[] = new byte[(maxNPCListSize+7) >> 3];
- public boolean withinDistance(Player otherPlr) {
- if(heightLevel != otherPlr.heightLevel) return false;
- int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
- return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
- }
- public boolean withinDistance(NPC npc) {
- if (heightLevel != npc.heightLevel) return false;
- if (npc.needRespawn == true) return false;
- int deltaX = npc.absX-absX, deltaY = npc.absY-absY;
- return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
- }
- public int distanceToPoint(int pointX,int pointY) {
- return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
- }
- public double toPoint(int pointX, int pointY) {
- int i1 = this.absX - pointX;
- int i2 = this.absY - pointY;
- return Math.sqrt(i1 * i1 + i2 * i2);
- }
- public int calculateSpeed(int i1, int i2) {
- int i3 = (int) (Math.round(this.toPoint(i1, i2)));
- @SuppressWarnings("unused")
- Client c = (Client)this;
- //c.sendMessage("distance is" + i3);
- //c.sendMessage("my coords" + absX + "- " +absY);
- //c.sendMessage("his coords" + i1 + "- " + i2);
- for(int i = 1; i < 8; i++) {
- if(i3 <= i) {
- int i4 = (i + 5) * 10;
- //c.sendMessage("speed is" + i4);
- return i4;
- }
- }
- return 110;
- }
- public int mapRegionX, mapRegionY;
- public int absX, absY;
- public int currentX, currentY;
- public int heightLevel;
- public int playerSE = 0x328;
- public int playerSEW = 0x333;
- public int playerSER = 0x334;
- public boolean updateRequired = true;
- public final int walkingQueueSize = 50;
- public int walkingQueueX[] = new int[walkingQueueSize], walkingQueueY[] = new int[walkingQueueSize];
- public int wQueueReadPtr = 0;
- public int wQueueWritePtr = 0;
- public int teleportToX = -1, teleportToY = -1;
- public void resetWalkingQueue() {
- wQueueReadPtr = wQueueWritePtr = 0;
- for(int i = 0; i < walkingQueueSize; i++) {
- walkingQueueX[i] = currentX;
- walkingQueueY[i] = currentY;
- }
- }
- public void addToWalkingQueue(int x, int y) {
- //if (VirtualWorld.I(heightLevel, absX, absY, x, y, 0)) {
- int next = (wQueueWritePtr+1) % walkingQueueSize;
- if(next == wQueueWritePtr) return;
- walkingQueueX[wQueueWritePtr] = x;
- walkingQueueY[wQueueWritePtr] = y;
- wQueueWritePtr = next;
- //}
- }
- public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
- for (int i = 0; i <= distance; i++) {
- for (int j = 0; j <= distance; j++) {
- if ((objectX + i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
- return true;
- } else if ((objectX - i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
- return true;
- } else if (objectX == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
- return true;
- }
- }
- }
- return false;
- }
- public int getNextWalkingDirection() {
- if(wQueueReadPtr == wQueueWritePtr) return -1;
- int dir;
- do {
- dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
- if(dir == -1) wQueueReadPtr = (wQueueReadPtr+1) % walkingQueueSize;
- else if((dir&1) != 0) {
- resetWalkingQueue();
- return -1;
- }
- } while((dir == -1) && (wQueueReadPtr != wQueueWritePtr));
- if(dir == -1) return -1;
- dir >>= 1;
- currentX += Misc.directionDeltaX[dir];
- currentY += Misc.directionDeltaY[dir];
- absX += Misc.directionDeltaX[dir];
- absY += Misc.directionDeltaY[dir];
- if (isRunning()) {
- Client c = (Client) this;
- if (runEnergy > 0) {
- if (System.currentTimeMillis() > c.getPA().getAgilityRunDrain() + lastRunDrain) {
- runEnergy--;
- lastRunDrain = System.currentTimeMillis();
- c.getPA().sendFrame126(runEnergy + "%", 149);
- }
- } else {
- runOption = false;
- c.getPA().sendFrame87(173, 0);
- }
- }
- return dir;
- }
- public boolean didTeleport = false;
- public boolean mapRegionDidChange = false;
- public int dir1 = -1, dir2 = -1;
- public boolean createItems = false;
- public int poimiX = 0, poimiY = 0;
- public void getNextPlayerMovement() {
- mapRegionDidChange = false;
- didTeleport = false;
- dir1 = dir2 = -1;
- if(teleportToX != -1 && teleportToY != -1) {
- mapRegionDidChange = true;
- if(mapRegionX != -1 && mapRegionY != -1) {
- int relX = teleportToX-mapRegionX*8, relY = teleportToY-mapRegionY*8;
- if(relX >= 2*8 && relX < 11*8 && relY >= 2*8 && relY < 11*8)
- mapRegionDidChange = false;
- }
- if(mapRegionDidChange) {
- mapRegionX = (teleportToX>>3)-6;
- mapRegionY = (teleportToY>>3)-6;
- }
- currentX = teleportToX - 8*mapRegionX;
- currentY = teleportToY - 8*mapRegionY;
- absX = teleportToX;
- absY = teleportToY;
- resetWalkingQueue();
- teleportToX = teleportToY = -1;
- didTeleport = true;
- } else {
- dir1 = getNextWalkingDirection();
- if(dir1 == -1) {
- return;
- }
- if ((runOption || isNewWalkCmdIsRunning()) && runEnergy > 0) {
- dir2 = getNextWalkingDirection();
- }
- byte deltaX = 0;
- byte deltaY = 0;
- if(this.currentX < 16) {
- deltaX = 32;
- this.mapRegionX -= 4;
- this.mapRegionDidChange = true;
- } else if(this.currentX >= 88) {
- deltaX = -32;
- this.mapRegionX += 4;
- this.mapRegionDidChange = true;
- }
- if(this.currentY < 16) {
- deltaY = 32;
- this.mapRegionY -= 4;
- this.mapRegionDidChange = true;
- } else if(this.currentY >= 88) {
- deltaY = -32;
- this.mapRegionY += 4;
- this.mapRegionDidChange = true;
- }
- if(this.mapRegionDidChange) {
- this.currentX += deltaX;
- this.currentY += deltaY;
- for(int i = 0; i < 50; ++i) {
- this.walkingQueueX[i] += deltaX;
- this.walkingQueueY[i] += deltaY;
- }
- setLocation(getLocation());
- }
- }
- }
- public boolean isDonator() {
- return (isDonator > 0);
- }
- private boolean isSuperDonator() {
- return (isDonator == 2);
- }
- public void updateThisPlayerMovement(Stream str) {
- if(mapRegionDidChange) {
- str.createFrame(73);
- str.writeWordA(mapRegionX+6);
- str.writeWord(mapRegionY+6);
- }
- if(didTeleport) {
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- str.writeBits(2, 3);
- str.writeBits(2, heightLevel);
- str.writeBits(1, 1);
- str.writeBits(1, (updateRequired) ? 1 : 0);
- str.writeBits(7, currentY);
- str.writeBits(7, currentX);
- return ;
- }
- if(dir1 == -1) {
- // don't have to update the character position, because we're just standing
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- isMoving = false;
- if(updateRequired) {
- // tell client there's an update block appended at the end
- str.writeBits(1, 1);
- str.writeBits(2, 0);
- } else {
- str.writeBits(1, 0);
- }
- if (DirectionCount < 50) {
- DirectionCount++;
- }
- } else {
- DirectionCount = 0;
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- if(dir2 == -1) {
- isMoving = true;
- str.writeBits(2, 1);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- if(updateRequired) str.writeBits(1, 1);
- else str.writeBits(1, 0);
- }
- else {
- isMoving = true;
- str.writeBits(2, 2);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
- if(updateRequired) str.writeBits(1, 1);
- else str.writeBits(1, 0);
- }
- }
- }
- public void updatePlayerMovement(Stream str) {
- if(dir1 == -1) {
- if(updateRequired || isChatTextUpdateRequired()) {
- str.writeBits(1, 1);
- str.writeBits(2, 0);
- }
- else str.writeBits(1, 0);
- }
- else if(dir2 == -1) {
- str.writeBits(1, 1);
- str.writeBits(2, 1);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
- }
- else {
- str.writeBits(1, 1);
- str.writeBits(2, 2);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
- str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
- }
- }
- public byte cachedPropertiesBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
- public void addNewNPC(NPC npc, Stream str, Stream updateBlock) { //synchronized(this) {
- if(npcListSize == 255) {
- return;
- }
- int id = npc.npcId;
- npcInListBitmap[id >> 3] |= 1 << (id&7);
- npcList[npcListSize++] = npc;
- str.writeBits(14, id);
- int z = npc.absY-absY;
- if(z < 0) z += 32;
- str.writeBits(5, z);
- z = npc.absX-absX;
- if(z < 0) z += 32;
- str.writeBits(5, z);
- str.writeBits(1, 0);
- str.writeBits(16, npc.npcType); // Nicknames eller vanliga 14 - 12
- boolean savedUpdateRequired = npc.updateRequired;
- npc.updateRequired = true;
- npc.appendNPCUpdateBlock(updateBlock);
- npc.updateRequired = savedUpdateRequired;
- str.writeBits(1, 1);
- }
- public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
- //synchronized(this) {
- if(playerListSize == 255) {
- return;
- }
- int id = plr.playerId;
- playerInListBitmap[id >> 3] |= 1 << (id&7);
- playerList[playerListSize++] = plr;
- str.writeBits(11, id);
- str.writeBits(1, 1);
- boolean savedFlag = plr.isAppearanceUpdateRequired();
- boolean savedUpdateRequired = plr.updateRequired;
- plr.setAppearanceUpdateRequired(true);
- plr.updateRequired = true;
- plr.appendPlayerUpdateBlock(updateBlock);
- plr.setAppearanceUpdateRequired(savedFlag);
- plr.updateRequired = savedUpdateRequired;
- str.writeBits(1, 1);
- int z = plr.absY-absY;
- if(z < 0) z += 32;
- str.writeBits(5, z);
- z = plr.absX-absX;
- if(z < 0) z += 32;
- str.writeBits(5, z);
- //}
- }
- public int DirectionCount = 0;
- public boolean appearanceUpdateRequired = true;
- public int hitDiff2;
- public int hitDiff = 0;
- public boolean hitUpdateRequired2;
- public boolean hitUpdateRequired = false;
- public boolean isDead = false;
- public boolean isDying = false;
- protected static Stream playerProps;
- static {
- playerProps = new Stream(new byte[100]);
- }
- protected void appendPlayerAppearance(Stream str) {
- playerProps.currentOffset = 0;
- playerProps.writeByte(playerAppearance[0]);
- playerProps.writeByte(headIcon);
- playerProps.writeByte(headIconPk);
- if(!pNpc) {
- if (playerEquipment[playerHat] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerHat]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerCape] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerCape]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerAmulet] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerAmulet]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerWeapon] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerWeapon]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerChest] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerChest]);
- } else {
- playerProps.writeWord(0x100+playerAppearance[2]);
- }
- if (playerEquipment[playerShield] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerShield]);
- } else {
- playerProps.writeByte(0);
- }
- if (!Item.isFullBody(playerEquipment[playerChest])) {
- playerProps.writeWord(0x100+playerAppearance[3]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerLegs] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerLegs]);
- } else {
- playerProps.writeWord(0x100+playerAppearance[5]);
- }
- if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat]) && playerEquipment[playerHat] != 13362 && playerEquipment[playerHat] != 13350) {
- playerProps.writeWord(0x100 + playerAppearance[1]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[playerHands] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerHands]);
- } else {
- playerProps.writeWord(0x100+playerAppearance[4]);
- }
- if (playerEquipment[playerFeet] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[playerFeet]);
- } else {
- playerProps.writeWord(0x100+playerAppearance[6]);
- }
- if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[playerHat]) && playerEquipment[playerHat] != 13362 && playerEquipment[playerHat] != 13350) {
- playerProps.writeWord(0x100 + playerAppearance[7]);
- } else {
- playerProps.writeByte(0);
- }
- } else {
- playerProps.writeWord(-1);
- playerProps.writeWord(pNpc ? pNpcId : 2626);
- }
- playerProps.writeByte(playerAppearance[8]);
- playerProps.writeByte(playerAppearance[9]);
- playerProps.writeByte(playerAppearance[10]);
- playerProps.writeByte(playerAppearance[11]);
- playerProps.writeByte(playerAppearance[12]);
- playerProps.writeWord(playerStandIndex); // standAnimIndex
- playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
- playerProps.writeWord(playerWalkIndex); // walkAnimIndex
- playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
- playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
- playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
- playerProps.writeWord(playerRunIndex); // runAnimIndex
- playerProps.writeQWord(Misc.playerNameToInt64(playerName));
- combatLevel = calculateCombatLevel();
- playerProps.writeByte(combatLevel);
- playerProps.writeByte(playerTitle);
- playerProps.writeByte(isDonator);
- playerProps.writeWord(0);
- str.writeByteC(playerProps.currentOffset);
- str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
- }
- public int calculateCombatLevel() {
- int magic = (int) ((getLevelForXP(playerXP[6])) * 1.5);
- int ranged = (int) ((getLevelForXP(playerXP[4])) * 1.5);
- int melee = (int) ((double) (getLevelForXP(playerXP[0])) +
- (double) (getLevelForXP(playerXP[2])));
- int summoning = (int)(getLevelForXP(playerXP[22]) * 0.125);
- int combatLevel = (int) (summoning + (getLevelForXP(playerXP[1]) * 0.25) +
- (getLevelForXP(playerXP[5]) * 0.125));
- if (ranged > melee) {
- combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
- (getLevelForXP(playerXP[4]) * 0.4875));
- } else if (magic > melee) {
- combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
- (getLevelForXP(playerXP[6]) * 0.4875));
- } else {
- combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
- (getLevelForXP(playerXP[0]) * 0.325) +
- (getLevelForXP(playerXP[2]) * 0.325));
- }
- return combatLevel;
- }
- public int calculateMaxLifePoints() {
- int lifePoints = getLevelForXP(playerXP[3]);//The normal hp
- int torvaLegs = 13360;//Torva Legs id
- int torvaBody = 13358;//Torva Body id
- int torvaHelm = 13362;//Torva Helm id
- int pernixLegs = 13352;//Pernix Chaps id
- int pernixBody = 13354;//Pernix Body id
- int pernixHelm = 13355;//Pernix Cowl id
- int virtusLegs = 13346;//Virtus Robe bottom id
- int virtusBody = 13348;//Virtus Robe top id
- int virtusHelm = 13346;//Virtus Mask id
- if (playerEquipment[playerLegs] == torvaLegs || playerEquipment[playerLegs] == pernixLegs || playerEquipment[playerLegs] == virtusLegs) {
- lifePoints += 13;
- }
- if (playerEquipment[playerChest] == torvaBody || playerEquipment[playerChest] == pernixBody || playerEquipment[playerChest] == virtusBody) {
- lifePoints += 20;
- }
- if (playerEquipment[playerHat] == torvaHelm || playerEquipment[playerHat] == pernixHelm || playerEquipment[playerHat] == virtusHelm) {
- lifePoints += 7;
- }
- return lifePoints;
- }
- public int getLevelForXP(int exp) {
- int points = 0;
- int output = 0;
- for (int lvl = 1; lvl <= 99; lvl++) {
- points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
- output = (int)Math.floor(points / 4);
- if (output >= exp)
- return lvl;
- }
- return 99;
- }
- private boolean chatTextUpdateRequired = false;
- private byte chatText[] = new byte[4096];
- private byte chatTextSize = 0;
- private int chatTextColor = 0;
- private int chatTextEffects = 0;
- protected void appendPlayerChatText(Stream str) {
- str.writeWordBigEndian(((getChatTextColor()&0xFF) << 8) + (getChatTextEffects()&0xFF));
- str.writeByte(playerRights);
- str.writeByteC(getChatTextSize());
- str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
- }
- public void forcedChat(String text) {
- forcedText = text;
- forcedChatUpdateRequired = true;
- updateRequired = true;
- setAppearanceUpdateRequired(true);
- }
- public String forcedText = "null";
- public void appendForcedChat(Stream str) {
- str.writeString(forcedText);
- }
- /**
- *Graphics
- **/
- public int mask100var1 = 0;
- public int mask100var2 = 0;
- protected boolean mask100update = false;
- public void appendMask100Update(Stream str) {
- str.writeWordBigEndian(mask100var1);
- str.writeDWord(mask100var2);
- }
- public void gfx100(int gfx) {
- mask100var1 = gfx;
- mask100var2 = 6553600;
- mask100update = true;
- updateRequired = true;
- }
- public void gfx50(int gfx) {
- mask100var1 = gfx;
- mask100var2 = 65536 * 50;
- mask100update = true;
- updateRequired = true;
- }
- public void customGfx(int gfx, int height, int delay) {
- mask100var1 = gfx;
- mask100var2 = (65536*height)+delay;
- mask100update = true;
- updateRequired = true;
- }
- public void gfx0(int gfx) {
- if(isDoingSkillcapeAnim)
- return;
- mask100var1 = gfx;
- mask100var2 = 65536;
- mask100update = true;
- updateRequired = true;
- }
- public boolean wearing2h() {
- Client c = (Client)this;
- String s = c.getItems().getItemName(c.playerEquipment[c.playerWeapon]);
- if (s.contains("2h"))
- return true;
- else if (s.contains("godsword"))
- return true;
- return false;
- }
- /**
- *Animations
- **/
- public void startAnimation(int animId) {
- animationRequest = animId;
- animationWaitCycles = 0;
- updateRequired = true;
- }
- public void startAnimation(int animId, int time) {
- animationRequest = animId;
- animationWaitCycles = time;
- updateRequired = true;
- }
- public void appendAnimationRequest(Stream str) {
- str.writeWordBigEndian((animationRequest== -1) ? 65535 : animationRequest);
- str.writeByteC(animationWaitCycles);
- }
- /**
- *Face Update
- **/
- protected boolean faceUpdateRequired = false;
- public int face = -1;
- public int FocusPointX = -1, FocusPointY = -1;
- public void faceUpdate(int index) {
- face = index;
- faceUpdateRequired = true;
- updateRequired = true;
- }
- public void appendFaceUpdate(Stream str) {
- str.writeWordBigEndian(face);
- }
- public void turnPlayerTo(int pointX, int pointY){
- FocusPointX = 2*pointX+1;
- FocusPointY = 2*pointY+1;
- updateRequired = true;
- }
- private void appendSetFocusDestination(Stream str) {
- str.writeWordBigEndianA(FocusPointX);
- str.writeWordBigEndian(FocusPointY);
- }
- /**
- *Hit Update
- **/
- protected void appendHitUpdate(Stream str, int hitType, boolean isMax) {
- str.writeByte(getHitDiff()); // What the perseon got 'hit' for
- str.writeByteA((poisonMask == 1) ? 2 : (getHitDiff() > 0) ? 1 : 0);
- if (playerLevel[3] <= 0) {
- playerLevel[3] = 0;
- isDead = true;
- }
- str.writeByte(hitType);
- int hitMax = isMax ? 1 : 0;
- str.writeByte(hitMax);
- str.writeByte(soak);
- str.writeByte(hitOwner);
- str.writeByteC(playerLevel[3]); // Their current hp, for HP bar
- str.writeByte(calculateMaxLifePoints()); // Their max hp, for HP bar
- }
- protected void appendHitUpdate2(Stream str, int hitType, boolean isMax) {
- boolean isPoison = (poisonMask == 1);
- str.writeByte(hitDiff2); // What the perseon got 'hit' for
- str.writeByteA((isPoison) ? 2 : (getHitDiff() > 0) ? 1 : 0);
- if (poisonMask == 2)
- poisonMask = -1;
- if (playerLevel[3] <= 0) {
- playerLevel[3] = 0;
- isDead = true;
- }
- str.writeByte(hitType);
- int hitMax = isMax ? ((isPoison) ? 0 : 1 ) : 0;
- str.writeByte(hitMax);
- int hitSoak = 0;
- str.writeByte((isPoison) ? 0 : hitSoak);
- str.writeByte(hitOwner);
- str.writeByte(playerLevel[3]); // Their current hp, for HP bar
- str.writeByte(calculateMaxLifePoints()); // Their max hp, for HP bar
- }
- public void appendPlayerUpdateBlock(Stream str){
- if(!updateRequired && !isChatTextUpdateRequired()) return; // nothing required
- int updateMask = 0;
- if (forceMovementUpdate) {
- updateMask |= 0x400;
- }
- if(mask100update) {
- updateMask |= 0x100;
- }
- if(animationRequest != -1) {
- updateMask |= 8;
- }
- if(forcedChatUpdateRequired) {
- updateMask |= 4;
- }
- if(isChatTextUpdateRequired()) {
- updateMask |= 0x80;
- }
- if(isAppearanceUpdateRequired()) {
- updateMask |= 0x10;
- }
- if(faceUpdateRequired) {
- updateMask |= 1;
- }
- if(FocusPointX != -1) {
- updateMask |= 2;
- }
- if (isHitUpdateRequired()) {
- updateMask |= 0x20;
- }
- if(hitUpdateRequired2) {
- updateMask |= 0x200;
- }
- if(updateMask >= 0x100) {
- updateMask |= 0x40;
- str.writeByte(updateMask & 0xFF);
- str.writeByte(updateMask >> 8);
- } else {
- str.writeByte(updateMask);
- }
- // now writing the various update blocks itself - note that their order crucial
- if (forceMovementUpdate) {
- appendMask400Update(str);
- }
- if(mask100update) {
- appendMask100Update(str);
- }
- if(animationRequest != -1) {
- appendAnimationRequest(str);
- }
- if(forcedChatUpdateRequired) {
- appendForcedChat(str);
- }
- if(isChatTextUpdateRequired()) {
- appendPlayerChatText(str);
- }
- if(faceUpdateRequired) {
- appendFaceUpdate(str);
- }
- if(isAppearanceUpdateRequired()) {
- appendPlayerAppearance(str);
- }
- if(FocusPointX != -1) {
- appendSetFocusDestination(str);
- }
- if(isHitUpdateRequired()) {
- appendHitUpdate(str, this.hitType, this.crit);
- }
- if(hitUpdateRequired2) {
- appendHitUpdate2(str, this.hitType, this.crit);
- }
- }
- public void clearUpdateFlags() {
- forceMovementUpdate = false;
- updateRequired = false;
- setChatTextUpdateRequired(false);
- setAppearanceUpdateRequired(false);
- setHitUpdateRequired(false);
- hitUpdateRequired2 = false;
- forcedChatUpdateRequired = false;
- mask100update = false;
- animationRequest = -1;
- FocusPointX = -1;
- FocusPointY = -1;
- faceUpdateRequired = false;
- face = 65535;
- poisonMask = -1;
- }
- public void stopMovement() {
- if(respawnTimer > 0 || isDead) {
- return;
- }
- if(teleportToX <= 0 && teleportToY <= 0) {
- teleportToX = absX;
- teleportToY = absY;
- }
- newWalkCmdSteps = 0;
- getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
- resetWalkingQueue();
- getNextPlayerMovement();
- }
- private int newWalkCmdX[] = new int[walkingQueueSize];
- private int newWalkCmdY[] = new int[walkingQueueSize];
- public int newWalkCmdSteps = 0;
- private boolean newWalkCmdIsRunning = false;
- protected int travelBackX[] = new int[walkingQueueSize];
- protected int travelBackY[] = new int[walkingQueueSize];
- protected int numTravelBackSteps = 0;
- public void preProcessing() {
- newWalkCmdSteps = 0;
- }
- public abstract void process();
- public abstract boolean processQueuedPackets();
- public void postProcessing() {
- if (newWalkCmdSteps > 0) {
- int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
- int lastDir = 0;
- boolean found = false;
- numTravelBackSteps = 0;
- int ptr = wQueueReadPtr;
- int dir = Misc.direction(currentX, currentY, firstX, firstY);
- if (dir != -1 && (dir & 1) != 0) {
- do {
- lastDir = dir;
- if (--ptr < 0) {
- ptr = walkingQueueSize - 1;
- }
- travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
- travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
- dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
- if (lastDir != dir) {
- found = true;
- break;
- }
- } while (ptr != wQueueWritePtr);
- } else {
- found = true;
- }
- if (!found) {
- println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
- resetWalkingQueue();
- stopMovement();
- // disconnected = true;
- } else {
- wQueueWritePtr = wQueueReadPtr;
- addToWalkingQueue(currentX, currentY);
- if (dir != -1 && (dir & 1) != 0) {
- for (int i = 0; i < numTravelBackSteps - 1; i++) {
- addToWalkingQueue(travelBackX[i], travelBackY[i]);
- }
- int wayPointX2 = travelBackX[numTravelBackSteps - 1], wayPointY2 = travelBackY[numTravelBackSteps - 1];
- int wayPointX1, wayPointY1;
- if (numTravelBackSteps == 1) {
- wayPointX1 = currentX;
- wayPointY1 = currentY;
- } else {
- wayPointX1 = travelBackX[numTravelBackSteps - 2];
- wayPointY1 = travelBackY[numTravelBackSteps - 2];
- }
- dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
- if (dir == -1 || (dir & 1) != 0) {
- println_debug("Fatal: The walking queue is corrupt! wp1=(" + wayPointX1 + ", " + wayPointY1 + "), " + "wp2=(" + wayPointX2 + ", " + wayPointY2 + ")");
- } else {
- dir >>= 1;
- found = false;
- int x = wayPointX1, y = wayPointY1;
- while (x != wayPointX2 || y != wayPointY2) {
- x += Misc.directionDeltaX[dir];
- y += Misc.directionDeltaY[dir];
- if ((Misc.direction(x, y, firstX, firstY) & 1) == 0) {
- found = true;
- break;
- }
- }
- if (!found) {
- println_debug("Fatal: Internal error: unable to determine connection vertex!" + " wp1=(" + wayPointX1 + ", " + wayPointY1 + "), wp2=(" + wayPointX2 + ", " + wayPointY2 + "), " + "first=(" + firstX + ", " + firstY + ")");
- } else {
- addToWalkingQueue(wayPointX1, wayPointY1);
- }
- }
- } else {
- for (int i = 0; i < numTravelBackSteps; i++) {
- addToWalkingQueue(travelBackX[i], travelBackY[i]);
- }
- }
- for (int i = 0; i < newWalkCmdSteps; i++) {
- addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
- }
- }
- }
- }
- public int getMapRegionX() {
- return mapRegionX;
- }
- public int getMapRegionY() {
- return mapRegionY;
- }
- public int getX() {
- return absX;
- }
- public int getY() {
- return absY;
- }
- public int getId() {
- return playerId;
- }
- public boolean inPcBoat() {
- return absX >= 2660 && absX <= 2663 && absY >= 2638 && absY <= 2643;
- }
- public boolean inPcGame() {
- return absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619;
- }
- public boolean inWG() {
- return absX >= 2837 && absX <= 2847 && absY >= 3535 && absY <= 3543;
- }
- public void setHitDiff(int hitDiff) {
- this.hitDiff = hitDiff;
- }
- public void setHitDiff2(int amount) {
- this.hitDiff2 = amount;
- }
- public int getHitDiff() {
- return hitDiff;
- }
- public int getHitDiff2() {
- return hitDiff2;
- }
- public void setHitUpdateRequired(boolean hitUpdateRequired) {
- this.hitUpdateRequired = hitUpdateRequired;
- }
- public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
- this.hitUpdateRequired2 = hitUpdateRequired2;
- }
- public boolean isHitUpdateRequired() {
- return hitUpdateRequired;
- }
- public boolean getHitUpdateRequired() {
- return hitUpdateRequired;
- }
- public boolean getHitUpdateRequired2() {
- return hitUpdateRequired2;
- }
- public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
- this.appearanceUpdateRequired = appearanceUpdateRequired;
- }
- public boolean isAppearanceUpdateRequired() {
- return appearanceUpdateRequired;
- }
- public void setChatTextEffects(int chatTextEffects) {
- this.chatTextEffects = chatTextEffects;
- }
- public int getChatTextEffects() {
- return chatTextEffects;
- }
- public void setChatTextSize(byte chatTextSize) {
- this.chatTextSize = chatTextSize;
- }
- public byte getChatTextSize() {
- return chatTextSize;
- }
- public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
- this.chatTextUpdateRequired = chatTextUpdateRequired;
- }
- public boolean isChatTextUpdateRequired() {
- return chatTextUpdateRequired;
- }
- public void setChatText(byte chatText[]) {
- this.chatText = chatText;
- }
- public byte[] getChatText() {
- return chatText;
- }
- public void setChatTextColor(int chatTextColor) {
- this.chatTextColor = chatTextColor;
- }
- public int getChatTextColor() {
- return chatTextColor;
- }
- public void setNewWalkCmdX(int newWalkCmdX[]) {
- this.newWalkCmdX = newWalkCmdX;
- }
- public int[] getNewWalkCmdX() {
- return newWalkCmdX;
- }
- public void setNewWalkCmdY(int newWalkCmdY[]) {
- this.newWalkCmdY = newWalkCmdY;
- }
- public int[] getNewWalkCmdY() {
- return newWalkCmdY;
- }
- public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
- this.newWalkCmdIsRunning = newWalkCmdIsRunning;
- }
- public boolean isNewWalkCmdIsRunning() {
- return newWalkCmdIsRunning;
- }
- @SuppressWarnings("unused")
- private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
- public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
- this.inStreamDecryption = inStreamDecryption;
- }
- public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
- this.outStreamDecryption = outStreamDecryption;
- }
- public boolean samePlayer() {
- for (int j = 0; j < PlayerHandler.players.length; j++) {
- if (j == playerId)
- continue;
- if (PlayerHandler.players[j] != null) {
- if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
- disconnected = true;
- return true;
- }
- }
- }
- return false;
- }
- public void putInCombat(int attacker) {
- underAttackBy = attacker;
- logoutDelay = System.currentTimeMillis();
- SpecialDelay = System.currentTimeMillis();
- singleCombatDelay = System.currentTimeMillis();
- }
- public void dealDamage(int damage) {
- if (!teleporting || teleportDelay == -1) {
- playerLevel[3] -= damage;
- Client c = (Client)this;
- c.getPA().refreshSkill(3);
- if (c.playerEquipment[c.playerAmulet] == 11090) {
- if(c.duelRule[6]) { return; }
- double hitpoints = c.getLevelForXP(c.playerXP[c.playerHitpoints]);
- double amtToHeal = hitpoints / 10 * 3;
- double correctHitpoints = hitpoints / 10 * 2;
- if (c.playerLevel[3] <= correctHitpoints
- && c.playerEquipment[c.playerAmulet] == 11090) {
- c.getItems().removeItem(c.playerEquipment[c.playerAmulet],
- c.playerAmulet);
- c.getItems().deleteItem2(11090, 1);
- c.playerLevel[3] += (int)amtToHeal;
- c.updateRequired = true;
- c.sendMessage("Your phoenix necklace heals you, but is destroyed in the process.");
- }
- }
- } else {
- if (hitUpdateRequired)
- hitUpdateRequired = false;
- if (hitUpdateRequired2)
- hitUpdateRequired2 = false;
- }
- }
- public void dealDamage(int damage, int hitType) {
- if (!teleporting || teleportDelay == -1) {
- playerLevel[3] -= damage;
- Client c = (Client)this;
- c.getPA().refreshSkill(3);
- handleHitMask(damage, hitType, 1);
- if (c.playerEquipment[c.playerAmulet] == 11090) {
- if(c.duelRule[6]) { return; }
- double hitpoints = c.getLevelForXP(c.playerXP[c.playerHitpoints]);
- double amtToHeal = hitpoints / 10 * 3;
- double correctHitpoints = hitpoints / 10 * 2;
- if (c.playerLevel[3] <= correctHitpoints
- && c.playerEquipment[c.playerAmulet] == 11090) {
- c.getItems().removeItem(c.playerEquipment[c.playerAmulet],
- c.playerAmulet);
- c.getItems().deleteItem2(11090, 1);
- c.playerLevel[3] += (int)amtToHeal;
- c.updateRequired = true;
- c.sendMessage("Your phoenix necklace heals you, but is destroyed in the process.");
- }
- }
- } else {
- if (hitUpdateRequired)
- hitUpdateRequired = false;
- if (hitUpdateRequired2)
- hitUpdateRequired2 = false;
- }
- }
- public int[] damageTaken = new int[Config.MAX_PLAYERS];
- public void handleHitMask(int damage, int hitType, int hitOwner) {
- if (!hitUpdateRequired) {
- hitUpdateRequired = true;
- hitDiff = damage;
- } else if (!hitUpdateRequired2) {
- hitUpdateRequired2 = true;
- hitDiff2 = damage;
- }
- this.hitType = hitType;
- this.hitOwner = hitOwner;
- updateRequired = true;
- }
- public Location location = getLocation();
- public Location getLocation() {
- return Location.create(absX, absY, heightLevel);
- }
- private Location lastKnownRegion = this.getLocation();
- private Region currentRegion = null;
- /**
- * Sets the last known map region.
- * @param lastKnownRegion The last known map region.
- */
- public void setLastKnownRegion(Location lastKnownRegion) {
- this.lastKnownRegion = lastKnownRegion;
- }
- /**
- * Gets the last known map region.
- * @return The last known map region.
- */
- public Location getLastKnownRegion() {
- return lastKnownRegion;
- }
- public Region getRegion() {
- return currentRegion;
- }
- /**
- * Removes this entity from the specified region.
- * @param region The region.
- */
- public abstract void removeFromRegion(Region region);
- /**
- * Adds this entity to the specified region.
- * @param region The region.
- */
- public abstract void addToRegion(Region region);
- /**
- * Sets the current location.
- * @param location The current location.
- */
- public void setLocation(Location location) {
- this.location = location;
- Region newRegion = World.getWorld().getRegionManager().getRegionByLocation(location);
- if(newRegion != currentRegion) {
- if(currentRegion != null) {
- removeFromRegion(currentRegion);
- }
- currentRegion = newRegion;
- addToRegion(currentRegion);
- }
- }
- /**
- * Gets the list of local npcs.
- * @return The list of local npcs.
- */
- public List<NPC> getLocalNPCs() {
- return localNpcs;
- }
- public List<Player> getLocalPlayers() {
- return localPlayers;
- }
- /**
- * The list of local npcs.
- */
- public List<NPC> localNpcs = new LinkedList<NPC>();
- public List<Player> localPlayers = new LinkedList<Player>();
- private Tickable walkToAction = null;
- public void setWalkToAction(Tickable walkToAction) {
- if(this.walkToAction != null) {
- this.walkToAction.stop();
- this.walkToAction = null;
- }
- if(walkToAction != null) {
- this.walkToAction = walkToAction;
- World.getWorld().submit(walkToAction);
- }
- }
- public Tickable getWalkToAction() {
- return walkToAction;
- }
- public PoisonDrainTick poisonDrainTick;
- public PoisonDrainTick getPoisonDrainTick() {
- return poisonDrainTick;
- }
- public void setPoisonDrainTick(PoisonDrainTick poisonDrainTick) {
- this.poisonDrainTick = poisonDrainTick;
- }
- public int getPlayerLevel(int level) {
- return getLevelForXP(playerXP[level]);
- }
- public void setForceMovement(final int x, final int y, final int speed1, final int speed2, final int direction, final int endAnim, final int time, final int height, final boolean stopPacket) {
- final int endX = getX() + x;
- final int endY = getY() + y;
- this.x1 = currentX;
- this.y1 = currentY;
- this.x2 = currentX + x;
- this.y2 = currentY + y;
- this.speed1 = speed1;
- this.speed2 = speed2;
- this.direction = direction;
- updateRequired = true;
- forceMovementUpdate = true;
- if (stopPacket) {
- stopPlayerPacket = true;
- }
- final Client c = (Client) this;
- World.getWorld().submit(new Tickable(time - 1) {
- @Override
- public void execute() {
- if (endAnim > 0) {
- c.startAnimation(endAnim);
- }
- this.stop();
- }
- });
- World.getWorld().submit(new Tickable(time) {
- @Override
- public void execute() {
- updateRequired = true;
- forceMovementUpdate = false;
- if (stopPacket) {
- stopPlayerPacket = false;
- }
- c.getPA().movePlayer(endX, endY, height);
- c.getCombat().getPlayerAnimIndex(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
- this.stop();
- }
- });
- }
- public void appendMask400Update(Stream str) {
- str.writeByteS(x1);
- str.writeByteS(y1);
- str.writeByteS(x2);
- str.writeByteS(y2);
- str.writeWordBigEndianA(speed1);
- str.writeWordA(speed2);
- str.writeByteS(direction);
- }
- }
Add Comment
Please, Sign In to add comment