Originally Posted by
knd6060
I was wondering about this couple weeks ago and had great info from Spooky in discord. It was in #rsps-general if you search for karam or cake you should find it fairly quick. Spooky posted some code at end that had implementation of delays for combo eating correctly as well.
I'll try summarize but i'll get some things wrong. Food, potions, and karam have separate timers. (Idk where guthix rest comes in).
Food is 3 tick delay except for pizza pie and cake which has 1 tick delays for first bite (second/third might be also 1 or more). (karam isnt food).
Potions have a separate timer and all potions have a 3 tick delay.
You can eat food and drink a potion in one tick if timers allow it.
You cannot drink a potion and then eat food in one tick.
So eating food will add on the delay of the food you eat. Drinking a potion will add on to potion delay.
When you drink a potion it only checks the potion delay.
When you eat food it checks both the food delay and the potion delay.
Karams add onto this is a bit. Karam has 3 tick delay and adds on when you eat karam.
You can eat food and then karam in one tick.
You can eat food drink a brew and then karam in one tick.
You cannot eat food, eat karam and then drink brew in one tick.
From here im not too sure.
The check for eating karam might be
If canKaram then
eat karam
Add karam delay (3 ticks) to all 3 timers
For food
if canFood
eat food
Add food delay to food timer
For pots
if canPot
Drink pot
Add pot delay (always 3 ticks) to pot timer
Add pot delay (3) to food timer
Please correct any mistakes or add extra info if you know it's correct. I still havent got around to implementing this.
Not entirely sure what im doing tbh, I can eat kara then angler tick correct but cant seem to eat angler then kara
Code:
int foodHealth = food.getHeal();
if (id == 13441) {
foodHealth = (int) Math.round(player.getMaxLevels()[3] + 0.23D);
}
int heal = player.getSkill().getLevels()[3] + foodHealth;
if (heal > player.getMaxLevels()[3]) {
if (id == 15272) {
heal = heal;
} else {
heal = player.getMaxLevels()[3];
}
}
if ((food.getReplaceId() == -1) && (consumable.getAmount() <= 1)) {
player.getInventory().clear(slot);
} else if ((food.getReplaceId() == -1) && (consumable.getAmount() > 1)) {
consumable.remove(1);
player.getInventory().update();
} else {
player.getInventory().setId(slot, food.getReplaceId());
}
player.getClient().queueOutgoingPacket(new SendSound(317, 1, 2));
player.getUpdateFlags().sendAnimation(829, 0);
if (player.getSkill().getLevels()[3] < heal) {
player.getSkill().setLevel(3, heal);
}
player.getClient().queueOutgoingPacket(new SendMessage(food.getMessage()));
AchievementHandler.activate(player, AchievementList.EAT_100_FOODS, 1);
player.getCombat().reset();
if (player.getCombat().getAttackTimer() > 0) {
player.getCombat().increaseAttackTimer(food.getDelay());
}
if (id != 3144) {
canEat = false;
}
TaskQueue.queue(new Task(player, food.getDelay(), false, Task.StackType.STACK, Task.BreakType.NEVER,
TaskIdentifier.CURRENT_ACTION) {
@Override
public void execute() {
canEat = true;
stop();
}
@Override
public void onStop() {
}
});
break;