Thread: [Elvarg / OSRSPK] Firemaking Skill

Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 33
  1. #21  
    Developer


    Join Date
    Oct 2013
    Age
    29
    Posts
    1,038
    Thanks given
    689
    Thanks received
    321
    Rep Power
    260
    Quote Originally Posted by S C A P E View Post
    Ive started to construct an abstract system for this and am doing another release using it, im hoping by Thursday. a lot of constructive criticism is helpful when doing something like this. Thanks for the reply man
    - Oscar
    EDIT i dont get what you mean by Also; just noticed that you're creating the ground item before deleting the log from the inventory. Should probably not do that. because it will get rid of the log first then place on floor and attempt to light (it should do) btw if you got the more accurate formulas can i have please cos the script i took from arios is from a bad programmer from 2013.
    If you create the ground item before removing the log from your inventory, theres a moment when the object is created but the log is still in your inventory. I'm assuming that he means someone could exploit this. If you removed the item and then created the object, there would be no way that the item could be in your inventory after the object is created. Good job though man, looks pretty good

    Edit: i just read through it an noticed you're deleting the item first then placing the object already. So idk lol

    Attached image
    Spoiler for vouches(20+):

    Reply With Quote  
     

  2. #22  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    Quote Originally Posted by Andys1814 View Post
    private final Firemaking firemaking = new Firemaking(this);

    player.getFiremaking().createFire()

    which is what most servers do

    and if you mean you should just do "new Firemaking(player)" in the item on item packet listener, then he should just use a skill action system from the start lol
    I get what you're saying, he is creating a new "Firemaking" object for each player, when;
    The skill data belongs to the player, but the actions and methods of a skill however do not, so this could be done in a static context
    where the player entity does not take ownership of the entire object we create and the methods they do not need ownership of.

    I currently have it handled statically myself.
    Code:
    public class Firemaking {
    	
    	public static void lightFire(final Player player, final Item item, final double experience, final int fireTimer) {
    		
    		final GroundItem logs = new GroundItem(new Item(item.getId()),
    				player.getPosition(), player.getUsername(), player.getHostAddress(), false, 150, true, 120);
    		
    		final GroundItem ashes = new GroundItem(SkillConstants.ASHES,
    				player.getPosition(), player.getUsername(), player.getHostAddress(), false, 150, true, 120);
    		
    		final GameObject fire = new GameObject(5249, player.getPosition(), 10, 0, fireTimer) {
    			@Override
    			public void onDespawn() {
    				GroundItemManager.spawnGroundItem(player, ashes);
    			}
    		};
    		
    		player.getMovementQueue().reset().setMovementStatus(MovementStatus.DISABLED);
    		player.performAnimation(SkillConstants.LIGHT_FIRE_ANIMATION);
    		player.getInventory().delete(item, item.getSlot());
    		GroundItemManager.spawnGroundItem(player, logs);
    		player.getAttributes().skillAnimationTimer.start(8);
    		player.getAttributes().setPerformingSkill(true);
    		
    		TaskManager.submit(new Task(1, player, true) {
    			@Override
    			public void execute() {
    				
    				final int level = player.getSkills().getMaxLevel(Skill.FIREMAKING);
    				final int differential = (level > 20 ? level / 10 : 1);
    				
    				if (!isRunning())
    					stop();
    				
    				if (player.getAttributes().skillAnimationTimer.finished()) {
    					player.getPacketSender().sendMessage("You failed to light the fire.");
    					player.getMovementQueue().setMovementStatus(MovementStatus.NONE);
    					stop();
    				}
    				if (Misc.inclusive(0, differential) == differential && !player.getAttributes().skillAnimationTimer.finished()) {
    					GroundItemManager.remove(logs, true);
    					ObjectHandler.spawnGlobalObject(fire);
    					player.performAnimation(Animation.DEFAULT_RESET_ANIMATION);
    					player.getMovementQueue().setMovementStatus(MovementStatus.NONE);
    					player.getSkills().addExperience(Skill.FIREMAKING, (int)(experience * 1.2));
    					MovementQueue.stepAway(player);
    					stop();
    				}
    			}
    			@Override
    			public void stop() {
    				player.getAttributes().finishSkillInteraction();
    				setEventRunning(false);
    				return;
    			}
    		});
    	}
    }
    There's only 1 other method in the class, but I feel its unique, so I don't really wanna post it
    Other than that, just needs a better way of handling the ratio of which the player fails to light a log.
    Obviously, yunno, like lower levels fail more frequently, and so on.
    I just have it cheap-fixed with a random calculation for now.

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  3. Thankful user:


  4. #23  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by VenomRS View Post
    There's still lots missing, but at least you're putting efforts somewhere.
    Also below could be smaller, even an array would suffice.

    Code:
    if (player.getMovementQueue().canWalk(1, 0)) {
    					player.getMovementQueue().walkStep(1, 0);
    				} else {
    					if (player.getMovementQueue().canWalk(-1, 0)) {
    						player.getMovementQueue().walkStep(-1, 0);
    					} else {
    						if (player.getMovementQueue().canWalk(0, -1)) {
    							player.getMovementQueue().walkStep(0, -1);
    						} else {
    							if (player.getMovementQueue().canWalk(0,1)) {
    								player.getMovementQueue().walkStep(0, 1);
    							}
    						}
    					}
    				}
    If you can tell me whats missing that would be nice!
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  5. #24  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    Quote Originally Posted by S C A P E View Post
    If you can tell me whats missing that would be nice!
    All you need is; MovementQueue.stepAway(player);

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  6. #25  
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Quote Originally Posted by Lumiere View Post
    All you need is; MovementQueue.stepAway(player);
    Thats not something thats missing.
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  7. #26  
    What's a sundial in the shade?

    Lumiere's Avatar
    Join Date
    May 2013
    Age
    27
    Posts
    543
    Thanks given
    224
    Thanks received
    100
    Rep Power
    113
    Quote Originally Posted by S C A P E View Post
    Thats not something thats missing.
    Look at the method I posted above for lighting a fire, you don't need all of that is the point.
    That's all it takes to;
    1.) drop the logs
    2.) create the ground item of the logs only for the player, that onDespawn will turn to ashes.
    3.) create a task for the player to attempt light the logs on fire
    4.) if successful create a fire with a timer for the specific log, and move away
    if unsuccessful notify the player and keep the logs on the ground to go global after a period if the player doesn't pick them back up.

    Spoiler for Revy is perfect:
    Reply With Quote  
     

  8. #27  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Andys1814 View Post
    That's not a bad idea.

    I usually don't criticize people for their naming, but while you're doing it, yours is wrong too. Enums are never plural because the data which they represent is always singular. I.e. one type of log. For fishing, one type of fish. You call it by Fish.Shark for examples.
    You're correct about the name of an enumeration representing a singular type of data. However, you would never reference Fish.Shark, the correct conventional naming would be Fish.SHARK.
    Reply With Quote  
     

  9. Thankful users:


  10. #28  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Quote Originally Posted by Jason View Post
    You're correct about the name of an enumeration representing a singular type of data. However, you would never reference Fish.Shark, the correct conventional naming would be Fish.SHARK.
    Should post a reference so people can read lol

    Enum Types (The Javaâ„¢ Tutorials > Learning the Java Language > Classes and Objects)

    Oracle says...
    Because they are constants, the names of an enum type's fields are in uppercase letters.
    Although Oracle themselves are hippocrates, look at the color class.

    https://docs.oracle.com/javase/7/doc...awt/Color.html

    Quote Originally Posted by Andys1814 View Post
    private final Firemaking firemaking = new Firemaking(this);

    player.getFiremaking().createFire()

    which is what most servers do

    and if you mean you should just do "new Firemaking(player)" in the item on item packet listener, then he should just use a skill action system from the start lol
    Lombok does wonders mate

    Code:
    @Getter
    private final Firemaking firemaking = new Firemaking(this);
    Code:
    player.getFiremaking().doSomething();
    Attached image
    Reply With Quote  
     

  11. Thankful users:


  12. #29  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Freyr View Post
    Should post a reference so people can read lol

    Enum Types (The Javaâ„¢ Tutorials > Learning the Java Language > Classes and Objects)



    Although Oracle themselves are Hippocrates, look at the Color class.



    Lombok does wonders mate

    Code:
    @Getter
    private final Firemaking firemaking = new Firemaking(this);
    Code:
    player.getFiremaking().doSomething();
    Attached image

    mts mts
    Reply With Quote  
     

  13. #30  
    Номер 1


    Leanbow's Avatar
    Join Date
    Feb 2008
    Posts
    5,895
    Thanks given
    1,564
    Thanks received
    2,624
    Rep Power
    5000
    Quote Originally Posted by Andys1814 View Post
    lol so everytime a player lights a log a new player object is constructed?

    lol thats not good. Use an abstract skilling system to manage skills like these. Other than that it looks decent
    passing reference isn't player object constructed. P sure it would have to be
    Code:
    new Player
    to create new player object
    Reply With Quote  
     

  14. Thankful user:


Page 3 of 4 FirstFirst 1234 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: 8
    Last Post: 04-01-2015, 09:17 PM
  2. [Asteria 3.0] Adding the Firemaking skill.
    By CTucker in forum Tutorials
    Replies: 5
    Last Post: 03-29-2015, 08:36 PM
  3. [Niobe] Firemaking skill
    By DesolaceRSPS in forum Snippets
    Replies: 11
    Last Post: 03-16-2013, 03:10 AM
  4. Replies: 39
    Last Post: 02-10-2012, 04:48 AM
  5. Firemaking skill
    By Profile in forum Snippets
    Replies: 4
    Last Post: 09-03-2011, 06:43 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •