the number 100 would be the place where you'd specify the objectTicks, which is the amount of ticks youd want it to start ticking down for the object to be removed, if the value was 0, itd be a permanent object. unless you have alot of these things running around your server, this chunk of code being processed is pointless. either way, lets turn it into a task incase you do use this objectTick thing in the future.
/**
* Handles the object tick to remove a spawned object after a certain amount of time
* @author Final Project
*
*/
public class ObjectHandlerEvent extends CycleEvent {
CycleEventHandler.getSingleton().addEvent(c, new ObjectHandlerEvent(), 1);
no more process in objecthandler..
Code:
public void process() {
}
Spoiler for itemhandler:
Quote:
Originally Posted by Our Promise[Only registered and activated users can see links. Click Here To Register...]
okay got bored and started looking through other classes having things being processed through the main server tick and since i was in itemhandler already, i looked there first, this is the only thing ive found being processed in itemhandler
Code:
for(GroundItem i : Server.itemHandler.items) {
if(i.hideTicks > 0) {
i.hideTicks--;
}
if(i.hideTicks == 1) { // item can now be seen by others
i.hideTicks = 0;
Server.itemHandler.createGlobalItem(i);
i.removeTicks = ItemHandler.HIDE_TICKS;
}
if(i.removeTicks > 0) {
i.removeTicks--;
}
if(i.removeTicks == 1) {
i.removeTicks = 0;
Server.itemHandler.removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(), i.getItemAmount());
break;
}
}
so i was like k.. i can really just turn this to a simple task. so here we go..
/**
* Starts the task for ground item removal and hide ticks after an item is dropped
* @author Final Project
*
*/
public class GroundItemEvent extends CycleEvent {
@Override
public void execute(CycleEventContainer container) {
for(GroundItem i : Server.itemHandler.items) {
System.out.println(Integer.toString(i.hideTicks) + "hide");
System.out.println(Integer.toString(i.removeTicks) + "remove");
if(i.hideTicks > 0) {
i.hideTicks--;
}
if(i.hideTicks == 1) { // item can now be seen by others
i.hideTicks = 0;
Server.itemHandler.createGlobalItem(i);
i.removeTicks = ItemHandler.HIDE_TICKS;
}
if(i.removeTicks > 0) {
i.removeTicks--;
}
if(i.removeTicks == 1) {
i.removeTicks = 0;
Server.itemHandler.removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(), i.getItemAmount());
container.stop();
break;
}
}
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
}
Code:
/**
* Creates the ground item
**/
public void createGroundItem(Client c, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
if(itemId > 0) {
c.getItems().createGroundItem(itemId, itemX, itemY, itemAmount);
GroundItem item = new GroundItem(itemId, itemX, itemY, itemAmount, c.playerId, HIDE_TICKS);
CycleEventHandler.getSingleton().addEvent(c, new GroundItemEvent(), 1);
addItem(item);
}
}
no more things being processed in my itemhandler
Code:
public void process() {
}
sorry if im annoying people with all my process removal threads, but at least im contributing. these shits shouldve been released years ago.
Spoiler for runenergy:
Quote:
Originally Posted by Our Promise[Only registered and activated users can see links. Click Here To Register...]
I know most of you pi users use this as your run energy alternative [Only registered and activated users can see links. Click Here To Register...]
which uses process, so i thought id convert it to a task for ya to help you yet again remove something out of process and hopefully help you understand that there are always alternatives than just throwing things in process
/**
* The task to reduce prayer points for prayer activation
* @author Final Project
*
*/
public class ReducePrayerEvent extends CycleEvent {
/**
* Creates an instance of the client
*/
private Client client;
/**
* Constructs the class for the client
* @param client
* the client
*/
public ReducePrayerEvent(Client client) {
this.client = client;
}
@Override
public void execute(CycleEventContainer container) {
/*comment this out, just something i used to get the drain rates*/
client.sendMessage(""+client.getCombat().getDrainRate());
/*checks if player has no prayer points or has gone down to the negatives or if they have no prayers activated*/
if (client.playerLevel[5] == 0
|| client.playerLevel[5] < 0
|| !client.getCombat().hasPrayerActive()) {
container.stop();
return;
}
/*the prayer delay of when to drain the prayer point, needs to be more accurate as i kinda just did whatever*/
if(System.currentTimeMillis() - client.prayerDelay > client.getCombat().getPrayerDelay()
&& client.usingPrayer) {
client.prayerDelay = System.currentTimeMillis();
/*checks if the client has more than 0 prayer points then starts the draining process*/
if (client.playerLevel[5] > 0) {
client.playerLevel[5] = (int) (client.playerLevel[5] - client.getCombat().getDrainRate());
client.getSkills().refreshSkill(5);
}
}
}
@Override
public void stop() {
if (client.playerLevel[5] < 0) {
client.playerLevel[5] = 0;
client.getSkills().refreshSkill(5);
}
client.getCombat().resetPrayers();
}
}
now call the task in your activateprayer method after the switch or wherever you want after that, scratch not, not just anywhere lol.
i used this guide as a reference for the formula, [Only registered and activated users can see links. Click Here To Register...] but i kinda didnt wanna do the math so you guys are welcomed to do that yourself.
edit: just noticed that i did something stupid, oh well :)
Spoiler for skulltimer:
Quote:
Originally Posted by Our Promise[Only registered and activated users can see links. Click Here To Register...]
/**
* Handles the teletimer task while teleporting
* @author Karma
*
*/
public class TeleportingEvent extends CycleEvent {
/**
* Creates an instance of the client
*/
private Client client;
/**
* Constructs the class for the client
* @param client
* the client
*/
public TeleportingEvent(Client client) {
this.client = client;
}
@Override
public void execute(CycleEventContainer container) {
client.sendMessage(""+client.teleTimer);
if (client.teleTimer == 0) {
container.stop();
return;
}
if (client.teleTimer > 0) {
client.teleTimer--;
if (!client.isDead) {
if (client.teleTimer == 1 && client.newLocation > 0) {
client.teleTimer = 0;
client.getPA().changeLocation();
}
if (client.teleTimer == 5) {
client.teleTimer--;
client.getPA().processTeleport();
}
if (client.teleTimer == 9 && client.teleGfx > 0) {
client.teleTimer--;
client.gfx100(client.teleGfx);
}
}
}
}
@Override
public void stop() {
client.teleTimer = 0;
}
}
now just call
CycleEventHandler.getSingleton().addEvent(null, new TeleportingEvent(c), 1);
wherever you have teleTimer declared more than 0, but be smart about it. example.
Code:
public void startTeleport(int x, int y, int height, String teleportType) {
if (teleportType.equalsIgnoreCase("dung") && c.inWild()) {
c.sM("Really?");
return;
}
if (c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
c.sM("You can't teleport above level "
+ Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness.");
return;
}
if (c.duelStatus == 5) {
c.sM("You can't teleport during a duel!");
return;
}
if (c.inPits || c.viewingOrb || inPitsWait()
|| c.championWar.inWaitRoom() || c.championWar.team != 0) {
c.sM("You can't teleport in here!");
return;
}
if (c.cantWalk) {
return;
}
if (c.getFog().inFog(c)) {
c.sM("You can not teleport out of FOG");
return;
}
if (c.inGWD()) {
ResetGWKC();
}
if (c.inJail() && c.Jail == true) {
c.sM("You can't teleport out of prison idiot!");
return;
}
if (c.Jail == true) {
c.sM("You can't teleport out until you are dealt with!");
return;
}
if (c.inWarriorG() && c.heightLevel == 2) {
c.sM("You can't teleport out of Warrior Guild!");
return;
}
if (c.inPcGame()) {
c.sM("What are you trying to do? Protect the Void Knight!");
return;
}
if (c.inRFD()) {
c.sM("You can't teleport out of this minigame!");
return;
}
if (c.inFunPk() && c.underAttackBy > 0) {
c.sM("You can not teleport in fun pk!");
return;
}
if (c.inFightCaves()) {
c.sM("You can't teleport out of this minigame!");
return;
}
if (c.inWild() && c.wildLevel > Config.NO_TELEPORT_WILD_LEVEL) {
c.sM("You can't teleport above level "
+ Config.NO_TELEPORT_WILD_LEVEL + " in the wilderness.");
return;
}
if (c.inDungeoneering && c.playerRights != 3) {
c.sM("Aren't you a smart guy?");
return;
}
if (System.currentTimeMillis() - c.teleBlockDelay < c.teleBlockLength) {
c.sM("You are teleblocked and can't teleport.");
return;
}
if (c.inWild()) {
if (!c.getItems().playerHasItem(563, 5)) {
c.sM("You need 5 law runes to teleport when in the wilderness.");
return;
} else {
c.getItems().deleteItem(563, 5);
}
}
if (!c.isDead && c.teleTimer == 0 && c.respawnTimer == -6) {
if (c.playerIndex > 0 || c.npcIndex > 0)
c.getCombat().resetPlayerAttack();
c.stopMovement();
EarningPotential.checkTeleport(c);
removeAllWindows();
c.teleX = x;
c.teleY = y;
c.npcIndex = 0;
c.playerIndex = 0;
c.faceUpdate(0);
c.teleHeight = height;
if (teleportType.equalsIgnoreCase("modern")) {
c.startAnimation(8939);
c.teleTimer = 9;
c.gfx0(1576);
c.teleEndAnimation = 8941;
}
if (teleportType.equalsIgnoreCase("abyss")) {
c.startAnimation(1816);
c.teleTimer = 9;
c.gfx0(342);
c.teleEndAnimation = 8941;
}
if (teleportType.equalsIgnoreCase("ancient")) {
c.startAnimation(9599);
c.teleGfx = 0;
c.teleTimer = 11;
c.teleEndAnimation = 8941;
c.gfx0(1681);
}
Your not really doing anything different at all with the objecthandler, itemhandler and what not as its still being processed every 600ms.
08-12-2014, 02:35 AM
Our Promise
Quote:
Originally Posted by Arithium[Only registered and activated users can see links. Click Here To Register...]
Your not really doing anything different at all with the objecthandler, itemhandler and what not as its still being processed every 600ms.
so ive been told. the objecthandler thing isnt even being used anyway
08-12-2014, 02:39 AM
Arithium
Quote:
Originally Posted by Our Promise[Only registered and activated users can see links. Click Here To Register...]
so ive been told. the objecthandler thing isnt even being used anyway
True to an extent, most objects that are 'constant' are loaded through the object manager. This is useful for things such as a minigame spawning objects for the life of the minigame, like for instance castle wars or something. Then you could just remove them after the minigame is over.
08-12-2014, 02:40 AM
danimals br0
Quote:
Originally Posted by Our Promise[Only registered and activated users can see links. Click Here To Register...]
so ive been told. the objecthandler thing isnt even being used anyway
then why you want to convert it to the task system if its not being used.
08-12-2014, 07:40 PM
Rhubarb
You're still calling the event(s) at unnecessary times, so there will be a lot of events. Also, none of the events have checked whether the player has been disconnected. Therefore, if the player starts like 5 events then logs out.. there would be no point in processing the events because the player has deregistered from the world. So just do something like:
Code:
if(player.disconnected) {
container.stop();
}
08-12-2014, 07:51 PM
Our Promise
Quote:
Originally Posted by Rhubarb[Only registered and activated users can see links. Click Here To Register...]
You're still calling the event(s) at unnecessary times, so there will be a lot of events. Also, none of the events have checked whether the player has been disconnected. Therefore, if the player starts like 5 events then logs out.. there would be no point in processing the events because the player has deregistered from the world. So just do something like:
Code:
if(player.disconnected) {
container.stop();
}
If they know how to call the events correctly specifying the object owner, adding the extra chek isn't really necessary.