Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void process() {
- for (int i = 0; i < maxNPCs; i++) {
- if (npcs[i] == null) continue;
- npcs[i].clearUpdateFlags();
- }
- for (int i = 0; i < maxNPCs; i++) {
- if (npcs[i] != null) {
- if(npcs[i].summon == true) {
- Client c = (Client)Server.playerHandler.players[npcs[i].spawnedBy];
- if(c != null && c.npcIndex > 0) {
- follownpc(i, c.npcIndex);
- }
- if(c != null && c.playerIndex < 1 && npcs[i].summon == true) {
- if(!npcs[i].underAttack) {
- if(!Server.playerHandler.players[npcs[i].spawnedBy].goodDistance(npcs[i].getX(), npcs[i].getY(), Server.playerHandler.players[npcs[i].spawnedBy].getX(), Server.playerHandler.players[npcs[i].spawnedBy].getY(), 2) && c.npcIndex < 1)
- followPlayer(i, c.playerId);
- }
- } else {
- if(c != null && npcs[i].summon == true) {
- if(!Server.playerHandler.players[npcs[i].spawnedBy].goodDistance(npcs[i].getX(), npcs[i].getY(), Server.playerHandler.players[npcs[i].spawnedBy].getX(), Server.playerHandler.players[npcs[i].spawnedBy].getY(), 5) && c.playerIndex < 1 || c.npcIndex < 1)
- {
- followPlayer(i, c.playerId);
- }
- }
- }
- if(c != null && c.lastsummon > 0 && !Server.playerHandler.players[npcs[i].spawnedBy].goodDistance(npcs[i].getX(), npcs[i].getY(), Server.playerHandler.players[npcs[i].spawnedBy].getX(), Server.playerHandler.players[npcs[i].spawnedBy].getY(), 10) && npcs[i].summon == true && !npcs[i].isDead)
- {
- npcs[i].isDead = true;
- npcs[i].applyDead = true;
- c.Summoning.SummonNewNPC(c.lastsummon);
- npcs[i].gfx0(1315);
- npcs[i].underAttackBy2 = -1;
- npcs[i].updateRequired = true;
- npcs[i].dirUpdateRequired = true;
- npcs[i].getNextWalkingDirection();
- }
- if(c != null && c.lastsummon < 0 || c == null)
- {
- npcs[i].isDead = true;
- npcs[i].applyDead = true;
- npcs[i].summon = false;
- npcs[i].underAttackBy2 = -1;
- }
- if(c != null && npcs[i].actionTimer < 1 && npcs[i].summon == true)
- {
- if(c.playerIndex > 0)
- {
- Client o = (Client)Server.playerHandler.players[c.playerIndex];
- if(o != null) {
- if(npcs[i].IsAttackingPerson = true && o.inMulti())
- {
- followPlayer(i, o.playerId);
- attackPlayer(o, i);
- npcs[i].index = o.playerId;
- npcs[i].actionTimer = 7;
- }
- }
- }
- }
- }
- if (npcs[i].npcType == 692) {
- if (Misc.random2(2) <= 3) {
- npcs[i].updateRequired = true;
- npcs[i].forceChat("Get ya Fresh 'ome grown Weed 'ere, 1 Dollar a Gram!");
- }
- }
- if (npcs[i].npcType ==2578) {
- if (Misc.random2(6) <= 20) {
- npcs[i].updateRequired = true;
- npcs[i].forceChat("All hail James! Thats right im a fanboy!!");
- npcs[i].forceChat("EVERYONE VOTE YES IM A WANNABE MOD!");
- npcs[i].forceChat("James is a sexy beast im going to follow him all day!");
- }
- }
- if (npcs[i].npcType == 659) {
- if (Misc.random2(2) <= 3) {
- npcs[i].updateRequired = true;
- npcs[i].forceChat("Welcome to the donator zone! Trade me ;)");
- }
- }
- if (npcs[i].actionTimer > 0) {
- npcs[i].actionTimer--;
- }
- if (npcs[i].freezeTimer > 0) {
- npcs[i].freezeTimer--;
- }
- if (npcs[i].hitDelayTimer > 0) {
- npcs[i].hitDelayTimer--;
- }
- if (npcs[i].hitDelayTimer == 1) {
- npcs[i].hitDelayTimer = 0;
- applyDamage(i);
- }
- if(npcs[i].attackTimer > 0) {
- npcs[i].attackTimer--;
- }
- if(npcs[i].spawnedBy > 0) { // delete summons npc
- if(Server.playerHandler.players[npcs[i].spawnedBy] == null
- || Server.playerHandler.players[npcs[i].spawnedBy].heightLevel != npcs[i].heightLevel
- || Server.playerHandler.players[npcs[i].spawnedBy].respawnTimer > 0
- || !Server.playerHandler.players[npcs[i].spawnedBy].goodDistance(npcs[i].getX(), npcs[i].getY(), Server.playerHandler.players[npcs[i].spawnedBy].getX(), Server.playerHandler.players[npcs[i].spawnedBy].getY(), 10)) {
- if(Server.playerHandler.players[npcs[i].spawnedBy] != null) {
- for(int o = 0; o < Server.playerHandler.players[npcs[i].spawnedBy].barrowsNpcs.length; o++){
- if(npcs[i].npcType == Server.playerHandler.players[npcs[i].spawnedBy].barrowsNpcs[o][0]) {
- if (Server.playerHandler.players[npcs[i].spawnedBy].barrowsNpcs[o][1] == 1)
- Server.playerHandler.players[npcs[i].spawnedBy].barrowsNpcs[o][1] = 0;
- }
- }
- }
- npcs[i] = null;
- }
- }
- if (npcs[i] == null) continue;
- /**
- * Attacking player
- **/
- if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && !switchesAttackers(i)) {
- npcs[i].killerId = getCloseRandomPlayer(i);
- } else if (isAggressive(i) && !npcs[i].underAttack && !npcs[i].isDead && switchesAttackers(i)) {
- npcs[i].killerId = getCloseRandomPlayer(i);
- }
- if (System.currentTimeMillis() - npcs[i].lastDamageTaken > 5000)
- npcs[i].underAttackBy = 0;
- if((npcs[i].killerId > 0 || npcs[i].underAttack) && !npcs[i].walkingHome && retaliates(npcs[i].npcType)) {
- if(!npcs[i].isDead) {
- int p = npcs[i].killerId;
- if(Server.playerHandler.players[p] != null) {
- Client c = (Client) Server.playerHandler.players[p];
- followPlayer(i, c.playerId);
- if (npcs[i] == null) continue;
- if(npcs[i].attackTimer == 0) {
- if(c != null) {
- attackPlayer(c, i);
- } else {
- npcs[i].killerId = 0;
- npcs[i].underAttack = false;
- npcs[i].facePlayer(0);
- }
- }
- } else {
- npcs[i].killerId = 0;
- npcs[i].underAttack = false;
- npcs[i].facePlayer(0);
- }
- }
- }
- /**
- * Random walking and walking home
- **/
- if (npcs[i] == null) continue;
- if((!npcs[i].underAttack || npcs[i].walkingHome) && npcs[i].randomWalk && !npcs[i].isDead) {
- npcs[i].facePlayer(0);
- npcs[i].killerId = 0;
- if(npcs[i].spawnedBy == 0) {
- if((npcs[i].absX > npcs[i].makeX + Config.NPC_RANDOM_WALK_DISTANCE) || (npcs[i].absX < npcs[i].makeX - Config.NPC_RANDOM_WALK_DISTANCE) || (npcs[i].absY > npcs[i].makeY + Config.NPC_RANDOM_WALK_DISTANCE) || (npcs[i].absY < npcs[i].makeY - Config.NPC_RANDOM_WALK_DISTANCE)) {
- npcs[i].walkingHome = true;
- }
- }
- if (npcs[i].walkingHome && npcs[i].absX == npcs[i].makeX && npcs[i].absY == npcs[i].makeY) {
- npcs[i].walkingHome = false;
- } else if(npcs[i].walkingHome) {
- npcs[i].moveX = GetMove(npcs[i].absX, npcs[i].makeX);
- npcs[i].moveY = GetMove(npcs[i].absY, npcs[i].makeY);
- npcs[i].getNextNPCMovement(i);
- npcs[i].updateRequired = true;
- }
- if(npcs[i].walkingType == 1) {
- if(Misc.random(3)== 1 && !npcs[i].walkingHome) {
- int MoveX = 0;
- int MoveY = 0;
- int Rnd = Misc.random(9);
- if (Rnd == 1) {
- MoveX = 1;
- MoveY = 1;
- } else if (Rnd == 2) {
- MoveX = -1;
- } else if (Rnd == 3) {
- MoveY = -1;
- } else if (Rnd == 4) {
- MoveX = 1;
- } else if (Rnd == 5) {
- MoveY = 1;
- } else if (Rnd == 6) {
- MoveX = -1;
- MoveY = -1;
- } else if (Rnd == 7) {
- MoveX = -1;
- MoveY = 1;
- } else if (Rnd == 8) {
- MoveX = 1;
- MoveY = -1;
- }
- if (MoveX == 1) {
- if (npcs[i].absX + MoveX < npcs[i].makeX + 1) {
- npcs[i].moveX = MoveX;
- } else {
- npcs[i].moveX = -1;
- }
- }
- if (MoveX == -1) {
- if (npcs[i].absX - MoveX > npcs[i].makeX - 1) {
- npcs[i].moveX = MoveX;
- } else {
- npcs[i].moveX = -1;
- }
- }
- if(MoveY == 1) {
- if(npcs[i].absY + MoveY < npcs[i].makeY + 1) {
- npcs[i].moveY = MoveY;
- } else {
- npcs[i].moveY = -1;
- }
- }
- if(MoveY == -1) {
- if(npcs[i].absY - MoveY > npcs[i].makeY - 1) {
- npcs[i].moveY = MoveY;
- } else {
- npcs[i].moveY = -1;
- }
- }
- int x = (npcs[i].absX + npcs[i].moveX);
- int y = (npcs[i].absY + npcs[i].moveY);
- if (VirtualWorld.I(npcs[i].heightLevel, npcs[i].absX, npcs[i].absY, x, y, 0))
- npcs[i].getNextNPCMovement(i);
- else
- {
- npcs[i].moveX = -1;
- npcs[i].moveY = -1;
- }
- npcs[i].updateRequired = true;
- }
- }
- }
- if (npcs[i].isDead == true) {
- if (npcs[i].actionTimer == 0 && npcs[i].applyDead == false && npcs[i].needRespawn == false) {
- npcs[i].updateRequired = true;
- npcs[i].facePlayer(0);
- npcs[i].killedBy = getNpcKillerId(i);
- npcs[i].animNumber = getDeadEmote(i); // dead emote
- npcs[i].animUpdateRequired = true;
- npcs[i].freezeTimer = 0;
- npcs[i].applyDead = true;
- killedBarrow(i);
- if (isFightCaveNpc(i))
- killedTzhaar(i);
- if(npcs[i].summon == true)
- npcs[i].summon = false;
- npcs[i].actionTimer = 4; // delete time
- resetPlayersInCombat(i);
- /*if (npcs[i].npcType == 1158){
- handleKalpite(i);
- }*/
- } else if (npcs[i] != null && npcs[i].actionTimer == 0 && npcs[i].applyDead == true && npcs[i].needRespawn == false) {
- //if (npcs[i] != null) {
- npcs[i].needRespawn = true;
- npcs[i].actionTimer = getRespawnTime(i); // respawn time
- dropItems(i); // npc drops items!
- appendSlayerExperience(i);
- //appendKillCount(i);
- Player.npcKills += 1;
- npcs[i].absX = npcs[i].makeX;
- npcs[i].absY = npcs[i].makeY;
- npcs[i].HP = npcs[i].MaxHP;
- npcs[i].animNumber = 0x328;
- npcs[i].updateRequired = true;
- npcs[i].animUpdateRequired = true;
- if (npcs[i].npcType >= 2440 && npcs[i].npcType <= 2446) {
- Server.objectManager.removeObject(npcs[i].absX, npcs[i].absY);
- }
- if (npcs[i].npcType == 2745) {
- handleJadDeath(i);
- }
- if (npcs[i].npcType == 3491) {
- handleRFDDeath(i);
- }
- if (npcs[i] != null && npcs[i].npcType != 1158){
- if (!npcs[i].needRespawn){
- npcs[i] = null;
- for (int j = 1; j < Config.MAX_PLAYERS; j++) {
- if (Server.playerHandler.players[j] != null) {
- Server.playerHandler.players[j].RebuildNPCList = true;
- }
- }
- continue;
- }
- npcs[i].needRespawn = true;
- npcs[i].actionTimer = 30;
- npcs[i].absX = npcs[i].makeX;
- npcs[i].absY = npcs[i].makeY - 1;
- } else if (npcs[i] != null && npcs[i].npcType == 1158) {
- npcs[i] = null;
- for (int j = 1; j < Config.MAX_PLAYERS; j++) {
- if (Server.playerHandler.players[j] != null){
- Server.playerHandler.players[j].RebuildNPCList = true;
- }
- }
- }
- } else if (npcs[i].actionTimer == 0 && npcs[i].needRespawn == true) {
- if(npcs[i].spawnedBy > 0) {
- npcs[i] = null;
- } else {
- /*if (npcs[i].actionTimer <= 0 && npcs[i].needRespawn && npcs[i].NeedsRespawn) {
- for (int j = 1; j < Config.MAX_PLAYERS; j++) {
- if (Server.playerHandler.players[j] != null) {
- Server.playerHandler.players[j].RebuildNPCList = true;
- }
- }*/
- int type = npcs[i].npcType;
- if (type == 1160)
- type = 1158;
- int x = npcs[i].makeX;
- int y = npcs[i].makeY;
- int height = npcs[i].heightLevel;
- int walk = npcs[i].walkingType;
- int mHp = npcs[i].MaxHP;
- int mHit = npcs[i].maxHit;
- int attack = npcs[i].attack;
- int defence = npcs[i].defence;
- npcs[i] = null;
- newNPC(type, x, y, height, walk, mHp, mHit, attack, defence);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement