Thread: Where to look regarding eating mechanics

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Where to look regarding eating mechanics 
    Registered Member
    Join Date
    Dec 2019
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    So i'm new to alot of this and I'm slowly getting a grasp on things.
    However, on my server i've encountered an issue where tick eating isn't possible, which is obviously frustrating. Where would be a good place to look to start getting to the route of the issue?

    Ive found the following in my FoodDefinitions.xml and it looks as if there shouldn't be an issue

    Code:
    	<FoodDefinition>
    		<id>3144</id>
    		<name>Cooked Karambwan</name>
    		<heal>18</heal>
    		<delay>0</delay>
    		<replaceId>0</replaceId>
    		<message>You eat the Cooked Karambwan.</message>
    Reply With Quote  
     

  2. #2  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,819
    Thanks received
    1,767
    Rep Power
    2438
    combo foods should have their own delay, not defined as regular foods, which is how you're doing it. modify the code to add a secondary delay for combo foods (karambs, pizzas).
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2019
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    combo foods should have their own delay, not defined as regular foods, which is how you're doing it. modify the code to add a secondary delay for combo foods (karambs, pizzas).
    Hmm okay, I think i understand, So they're still supposed to be within the food defintions, i just need to "define" another delay?
    Reply With Quote  
     

  4. #4  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,819
    Thanks received
    1,767
    Rep Power
    2438
    Quote Originally Posted by Swizz View Post
    Hmm okay, I think i understand, So they're still supposed to be within the food defintions, i just need to "define" another delay?
    modify the code to add a secondary delay for combo foods (karambs, pizzas).
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Dec 2019
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Tyluur View Post
    modify the code to add a secondary delay for combo foods (karambs, pizzas).
    Thanks, i did actually right a snarky reply but reflecting back on it, i see what you're saying
    Reply With Quote  
     

  6. #6  
    Registered Member
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    26
    Posts
    5,103
    Thanks given
    1,819
    Thanks received
    1,767
    Rep Power
    2438
    Quote Originally Posted by Swizz View Post
    Thanks, i did actually right a snarky reply but reflecting back on it, i see what you're saying
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Spoiler for skrrrrr:

    Attached image
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Sep 2016
    Posts
    181
    Thanks given
    84
    Thanks received
    74
    Rep Power
    452
    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.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Dec 2019
    Posts
    11
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by knd6060 View Post
    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;
    Reply With Quote  
     

  9. #9  
    Member of the Imagine Cult

    Join Date
    Feb 2013
    Posts
    519
    Thanks given
    21
    Thanks received
    7
    Rep Power
    59
    Uhh, i did this a bit ago so if I remember correctly it should have the following rules:

    1. Check if food has any unique requirements
    2. check if food has delay (all food except the special no tick foods, karam, pizza) *OR* if the last consumed food is equivalent to the food u're attempting to eat
    3. ^ if the last one is true, then u check to make sure player has waited the delay.

    - Pretty sure potions and food have their own delay, that's why you can stack them.
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Sep 2016
    Posts
    181
    Thanks given
    84
    Thanks received
    74
    Rep Power
    452
    Quote Originally Posted by Swizz View Post
    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;
    Jesus that code. Food delay should not be a task. Also this code is mainly eating and adding delay at end. But there is code earlier for canEat or checking if timers are good. Eitherway the system you have now wont support the behaviour we outlined. Need to rewrite parts of it.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 3
    Last Post: 03-03-2013, 07:41 AM
  2. Replies: 4
    Last Post: 01-08-2012, 11:10 AM
  3. Where to base my server?
    By RequaUK in forum RS2 Server
    Replies: 11
    Last Post: 03-27-2008, 09:57 AM
  4. Where to change clicking areas for...
    By Stanyer in forum RS2 Client
    Replies: 2
    Last Post: 03-09-2008, 08:44 PM
  5. Where to access Silab's client
    By Guthix in forum RS2 Client
    Replies: 9
    Last Post: 12-01-2007, 10:15 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •