Thread: Agility [Base]

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Agility [Base] 
    Ian...
    Guest
    Information;
    This is a shitty little bit of code i wrote when trying to add Agility into rs2d,
    I got it to auto move, though i need to figure some bits and bobs out first...

    I added the crumbling wall in Falador as a test obstical and well... instead of going west the player walks north lol.

    I wasnt realy sure what i was doing with the rs2d source as it gets a bit confusing...

    This is based on Jim's RS2DBase Version 1.

    Tutorial;
    First of all you need to make a new class in the net.varek.rs2d.content.skills and call it Agility, once done place all this in it;
    Code:
    package net.varek.rs2d.content.skills;
    
    import net.varek.rs2d.model.*;
    import net.varek.rs2d.packetbuilder.*;
    
    /**
     * Created by IntelliJ IDEA.
     * User: Ian
     * Date: 22-Jun-2008
     * Time: 05:35:15
     *
     *  @TODO Finish off and fix this fucker!
     */
    public class Agility implements SkillConstants {
    
        public static boolean do_obstical(int objectID, int objectX, int objectY, Player player) {
    		int reqlvl = 0;
                    int emote = 0;
                    int timer = 0;
                    int pathX =0, pathY = 0;
                    double xp = 0;
                    boolean isTeleport = false;
                    boolean wasRunning = false;
                    String message ="";
                    if(player.isRunning()){
                        player.setRunning(false);
                        wasRunning = true;
                    }
    		if(objectID == 2295){ // Log balance - gnome
                            timer = 8;
                            reqlvl = 1;
                            xp = 15;
                            pathX = 8;
                            pathY = 0;
                            emote = 762;
                            message = "You balance across the log.";
                    } else if(objectID == 11844){ // Crumbling wall - falador
                            timer = 3;
                            reqlvl = 1;  //5
                            xp = 15;
                            pathX = 0;
                            pathY = -2;
                            emote = 882;
                            message = "You climb over the crumbling wall.";
                    } else return false;
    
                    if(player.getMaxStat(AGILITY) >= reqlvl){
                        player.addXP(xp, AGILITY);
                        player.getActionSender().sendMessage(message);
                        if(wasRunning)
                            player.setRunning(true);
                        if(isTeleport){
                            player.setLocation(Point.location(pathX, pathY), true);
                            isTeleport = false;
                        } else {
                            player.setObsticalTimer(timer);
                            player.setObsticalUse(true);
                            player.getPathHandler().addPoint(Point.location((player.getX()+pathX), (player.getY()+pathY)));
                            PlayerUpdate.changeDefaultAnimation(2, emote); //Is 1 walking emote?
                        }
                    } else {
    			player.getActionSender().sendMessage("You need a Agility  level of "+reqlvl+" to do this obstical.");
    			}
            
                    return true;
                }
    
    }
    Now open net.varek.rs2d.packethandler.ObjectAction and find;
    Code:
    			@SuppressWarnings("unused")
    			static void handleFirstClick(Packet p, Player player, ActionSender sender){
    				int x = p.readLEShort();
    				int id = p.readShort();
    				int y = p.readShortA();
    
                    if(id == 2213){ //Bank booth
    					player.getActionSender().sendBagInterface(5292,5063);
    					player.getActionSender().sendResetInventory(5064);
    				}
    			}
    and replace it with;
    Code:
    @SuppressWarnings("unused")
    			static void handleFirstClick(Packet p, Player player, ActionSender sender){
    				int x = p.readLEShort();
    				int id = p.readShort();
    				int y = p.readShortA();
    
                    if(Agility.do_obstical(id, x,y,player)) return;
                    if(id == 2213){ //Bank booth
    					player.getActionSender().sendBagInterface(5292,5063);
    					player.getActionSender().sendResetInventory(5064);
    				}
    			}
    after that go into net.varek.rs2d.model.Player and add these methods and variables;
    Code:
                private int obsticalTimer = 0;
                private boolean usingObstical = false;
    Code:
                public void setObsticalTimer(int time) {
                    this.obsticalTimer = time;
                }
    
                public int getObsticalTimer() {
                    return obsticalTimer;
                }
    
                public void setObsticalUse(boolean using) {
                    this.usingObstical = using;
                }
    
                public boolean getObsticalUse() {
                    return usingObstical;
                }
    Now once that is done, go to net.varek.rs2d.packetbuilder.PlayerUpdate
    and find;
    Code:
    			private final static int[] ANIMATION_INDICES = {
    				0x328, 0x337, 0x333, 0x334, 0x335, 0x336, 0x338
    			};
    and replace it with this;
    Code:
    			private static int[] ANIMATION_INDICES = {
    				0x328, 0x337, 0x333, 0x334, 0x335, 0x336, 0x338
    			};
    
                           public static void changeDefaultAnimation(int i, int changeTo){
                                    ANIMATION_INDICES[i] = changeTo;
                           }
    Now go into net.varek.rs2d.ClientUpdater and search for
    Code:
    				//Reset NPC data
    				for(NPC n : npcs){
    					n.setSprite(-1); //needed this to stop them from moving every half second
    				}
    underneath that add;
    Code:
                    //Reset Agility
                    for(Player p : players) {
                        if(p.getObsticalTimer() > 0) {
                            p.setObsticalTimer(p.getObsticalTimer()-1);
                        }
                        if(p.getObsticalUse() && p.getObsticalTimer() == 0) {
                            PlayerUpdate.changeDefaultAnimation(1, 0x328);
                        }
                    }
    I think that is all, remember this was just a test to see if i could get it working or not lol, and well i failed so i decided to give u all the code i had, maybe you can build it up from the ashes

    - Ian...
    Last edited by Ian...; 06-23-2008 at 04:29 AM. Reason: Double posting is not allowed!
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Aug 2007
    Posts
    2,395
    Thanks given
    2
    Thanks received
    63
    Rep Power
    558
    ill check it out
    gj

    Jonas
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  3. #3  
    Ian...
    Guest
    Uhm Thanks
    Reply With Quote  
     

  4. #4  
    Ian...
    Guest
    i lost Vet cos i fail and no posts cos... well... i fail
    Reply With Quote  
     

  5. #5  
    Hauyser
    Guest
    Nice work Ian, gj.
    Reply With Quote  
     

  6. #6  
    Jim
    Jim is offline
    I dunno, its fine I guess

    Join Date
    Feb 2007
    Posts
    147
    Thanks given
    12
    Thanks received
    33
    Rep Power
    265
    I'll add this in and attempt to get it working

    (the directions etc)

    EDIT: You realize that changing those animation indexes changes that for everyone? The static way (which is what you did) at least .
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Sep 2007
    Posts
    1,394
    Thanks given
    3
    Thanks received
    2
    Rep Power
    323
    This base looks good. Good work even tho you didn't suceed hopefully Jim will.
    Reply With Quote  
     

  8. #8  
    Ian...
    Guest
    yeh Jim lad i didnt know what the Walking animation was so i couldnt edit it to make it llike...

    swap emote when u do the obstical, in my old Agility i had it under timer, when the timer reached 0 it would swap back to the standard emote.

    also in this i could not be assed making a whole method for auto walk so i just made it add to the Point.Location method...

    Code:
    player.getPathHandler().addPoint(Point.location((player.getX()+pathX), (player.getY()+pathY)));
    basicaly that line is adding the var pathY, wich in variable setting for the obsitcal will be set, like say pathX was 8 and pathY was 1

    it would getX() + 8 and getY() + 1, i couldnt think of a way to make it support subtraacting aswell as adding, but then im not realy sure how walking works to be honest, so have a good go at this mate, something good might come out of it.

    - Ian...
    Reply With Quote  
     

  9. #9  
    Jim
    Jim is offline
    I dunno, its fine I guess

    Join Date
    Feb 2007
    Posts
    147
    Thanks given
    12
    Thanks received
    33
    Rep Power
    265
    Quote Originally Posted by Ian... View Post
    so have a good go at this mate, something good might come out of it.

    - Ian...
    I worked on it... got it working fairly perfectly. Had to make a pretty nasty system for updating the walk animation unfortunately. I think you used the stand animation which would have required a lot more tinkering and perfection, and really Jagex doesn't have time for that, nor do we .

    Here's a vid of it:
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. #10  
    Registered Member druidje's Avatar
    Join Date
    Jan 2007
    Posts
    375
    Thanks given
    1
    Thanks received
    0
    Rep Power
    28
    Good job Ian

    Quote Originally Posted by zee_best View Post
    Get sarah101 to sleep with kevin?
    Quote Originally Posted by ject View Post
    but try ::noclit or whatever
    Developing 508!
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •