Thread: Ancient effigy

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Ancient effigy 
    _hassan

    Join Date
    Jul 2011
    Posts
    1,480
    Thanks given
    318
    Thanks received
    303
    Rep Power
    113
    Hi! On my private project, I made this which I thought I would like to share with you guys.

    I know this has been released before, but this features all animations and improved code.

    Please note that this does not include the dragonkin lamp, but I may release it in the nearest future.

    Code:
    package com.rs.game.player.content;
    
    import java.util.Arrays;
    
    
    import com.rs.game.Animation;
    import com.rs.game.Graphics;
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.player.dialogues.AncientEffigyD;
    
    
    /**
     *
     * @author _Hassan <https://www.rune-server.ee/members/_hassan/> Created: 18 Apr
     *         2017 ~ server
     *
     */
    
    
    public class AncientEffigy {
    
    
        private static AncientEffigy instance;
    
    
        public static final AncientEffigy getInstance() {
            if (instance == null)
                instance = new AncientEffigy();
            return instance;
        }
    
    
        private Item item;
    
    
        private final Object[][] EMOTES = { { new Animation(14177), new Graphics(2692) },
                { new Animation(4068), new Animation(4067) } };
    
    
        private final Item[] EFFIGIES = { new Item(18778), new Item(18779), new Item(18780), new Item(18781) };
    
    
        private final int[] SKILL_1 = { Skills.AGILITY, Skills.CONSTRUCTION, Skills.COOKING, Skills.FISHING,
                Skills.FLETCHING, Skills.HERBLORE, Skills.MINING, Skills.SUMMONING };
    
    
        private final int[] SKILL_2 = { Skills.CRAFTING, Skills.THIEVING, Skills.FIREMAKING, Skills.FARMING,
                Skills.WOODCUTTING, Skills.HUNTER, Skills.SMITHING, Skills.RUNECRAFTING };
    
    
        private final String[] SKILL_MESSAGES = { "deftness and precision", "buildings and security",
                "fire and preparation", "life and cultivation", "lumber and woodworking", "flora and fuana",
                "metalwork and minerals", "binding essence and spirits" };
    
    
        public boolean isEffigy(Player player, Item item) {
            this.item = item;
            if (item.getId() == effigy().getId()) {
                player.getDialogueManager().startDialogue(AncientEffigyD.class, item);
                return true;
            }
            return false;
        }
    
    
        public void advanceEffigy(Player player, Item item) {
            player.lock(5);
            player.getInventory().deleteItem(effigy().getId(), 1);
            player.getInventory().addItem(effigy().getId() + 1, 1);
            player.setNextAnimation((Animation) EMOTES[1][0]);
            if (effigy().getId() + 1 == 18782)
                player.setAniAndGfx((Animation) EMOTES[0][0], (Graphics) EMOTES[0][1]);
        }
    
    
        private final Item effigy() {
            return Arrays.stream(EFFIGIES).filter(effigy -> item.getId() == effigy.getId()).findAny().orElse(null);
        }
    
    
        public int[] getSkills(int type) {
            return type == 0 ? SKILL_1 : SKILL_2;
        }
    
    
        public String getMessage(int skill) {
            return SKILL_MESSAGES[skill];
        }
    
    
        public int getRequiredLvl(Item item) {
            switch (item.getId()) {
            case 18778:
                return 91;
            case 18779:
                return 93;
            case 18780:
                return 95;
            case 18781:
                return 97;
            }
            return -1;
        }
    
    
        public int getXP(Item item) {
            switch (item.getId()) {
            case 18778:
                return 15000;
            case 18779:
                return 20000;
            case 18780:
                return 25000;
            case 18781:
                return 30000;
            }
            return -1;
        }
    
    
    }

    Code:
    package com.rs.game.player.dialogues;
    
    import com.rs.GameSettings;
    import com.rs.game.item.Item;
    import com.rs.game.player.Skills;
    import com.rs.game.player.content.AncientEffigy;
    import com.rs.utils.Utils;
    
    
    /**
     *
     * @author _Hassan <https://www.rune-server.ee/members/_hassan/> Created: 19 Apr
     *         2017 ~ server
     *
     */
    
    
    public class AncientEffigyD extends Dialogue {
    
    
        Item item;
    
    
        int skill_1, skill_2;
    
    
        int random = Utils.random(AncientEffigy.getInstance().getSkills(0).length);
    
    
        @Override
        public void start() {
            item = (Item) parameters[0];
            skill_1 = AncientEffigy.getInstance().getSkills(0)[random];
            skill_2 = AncientEffigy.getInstance().getSkills(1)[random];
            stage = 1;
            sendDialogue(
                    "As you inspect the ancient effigy, you begin to feel a strange sensation of the relic searching your mind, drawing on your knowledge.");
        }
    
    
        @Override
        public void run(int interfaceId, int componentId) {
            switch (stage) {
            case END:
                end();
                break;
            case 1:
                sendDialogue("Images from your experiences of " + AncientEffigy.getInstance().getMessage(random)
                        + " fill your mind.");
                break;
            case 2:
                sendOptions("Which images do you wish to focus on?", Skills.SKILL_NAME[skill_1],
                        Skills.SKILL_NAME[skill_2]);
                break;
            case 3:
                switch (componentId) {
                case OPTION_1:
                case OPTION_2:
                    int required_lvl = AncientEffigy.getInstance().getRequiredLvl(item);
                    boolean op1 = componentId == OPTION_1;
                    if (op1 ? player.getSkills().getLevelForXp(skill_1) < required_lvl
                            : player.getSkills().getLevelForXp(skill_2) < required_lvl) {
                        stage = END;
                        sendDialogue(
                                "The images in your mind fade; the ancient effigy seems to desire knowledge of experiences you have not yet had.");
                        return;
    
    
                    }
                    int xp = AncientEffigy.getInstance().getXP(item) * GameSettings.XP_RATE;
                    player.getSkills().addXp(op1 ? skill_1 : skill_2, xp);
                    player.sm(
                            "You have gained " + Utils.formatNumber(xp) + " "
                                    + (op1 ? Skills.SKILL_NAME[skill_1] : Skills.SKILL_NAME[skill_2]) + " experience!",
                            false);
    
    
                    sendDialogue(
                            "As you focus on your memories, you can almost hear a voice in the back of your mind whispering to you...");
    
    
                }
                break;
            case 4:
                AncientEffigy.getInstance().advanceEffigy(player, item);
                sendDialogue(
                        "The ancient effigy glows briefly, it seems to be changed somehow and no longer responds to the same memories as before.");
                break;
            case 5:
                sendDialogue(
                        "A sudden bolt of inspiration flashes through your mind, revealling new insight into your experiences!");
    
    
                break;
            }
            stage++;
            if (stage == 6)
                end();
        }
    
    
        @Override
        public void finish() {
            // TODO Auto-generated method stub
    
    
        }
    
    
    }

    enjoy
    bye
    [Only registered and activated users can see links. ]

    Need to talk to me or have a question?

    Add me on skype: hassan_g3450
    Reply With Quote  
     

  2. #2  
    Registered Member Dot.'s Avatar
    Join Date
    Nov 2013
    Posts
    346
    Thanks given
    16
    Thanks received
    36
    Rep Power
    59
    good work bro won't use tho
    signature violation
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member omglolomghi's Avatar
    Join Date
    Oct 2013
    Posts
    739
    Thanks given
    216
    Thanks received
    128
    Rep Power
    24
    Great jobn as always


    Do not use the vps from ovh, blocking vps without reason and no customer support
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Registered Member
    Join Date
    Nov 2013
    Posts
    441
    Thanks given
    25
    Thanks received
    55
    Rep Power
    62
    nice leech bro try harder later.
    Reply With Quote  
     

  7. #5  
    _hassan

    Join Date
    Jul 2011
    Posts
    1,480
    Thanks given
    318
    Thanks received
    303
    Rep Power
    113
    Quote Originally Posted by Pwned901 View Post
    nice leech bro try harder later.
    what but thanks I guess
    [Only registered and activated users can see links. ]

    Need to talk to me or have a question?

    Add me on skype: hassan_g3450
    Reply With Quote  
     

  8. #6  
    Registered Member
    tommeh's Avatar
    Join Date
    Nov 2015
    Posts
    1,080
    Thanks given
    158
    Thanks received
    411
    Rep Power
    1261
    good job
    Reply With Quote  
     

  9. Thankful user:


  10. #7  
    Registered Member
    Kris's Avatar
    Join Date
    Jun 2016
    Age
    19
    Posts
    1,954
    Thanks given
    302
    Thanks received
    680
    Rep Power
    274
    Honestly idk why you're instancing this; everything is stand-alone here; should just set it all to static final.
    The previous released one was all fine, except.. It kept rolling the two skills.
    Idk I don't see a point but thanks for the release I guess.

    Reply With Quote  
     

  11. #8  
    _hassan

    Join Date
    Jul 2011
    Posts
    1,480
    Thanks given
    318
    Thanks received
    303
    Rep Power
    113
    Quote Originally Posted by Kris View Post
    Honestly idk why you're instancing this; everything is stand-alone here; should just set it all to static final.
    The previous released one was all fine, except.. It kept rolling the two skills.
    Idk I don't see a point but thanks for the release I guess.
    thanks4feedback

    also
    I know this has been released before, but this features all animations and improved code.
    [Only registered and activated users can see links. ]

    Need to talk to me or have a question?

    Add me on skype: hassan_g3450
    Reply With Quote  
     

  12. #9  
    Registered Member
    Join Date
    Nov 2014
    Posts
    49
    Thanks given
    9
    Thanks received
    5
    Rep Power
    0
    Why is item a variable and the class instanced for use? If you gonna make each item hold diff properties then implement serializable or extend Item

    Quote Originally Posted by _Hassan View Post
    Code:
    
        private final Item[] EFFIGIES = { new Item(18778), new Item(18779), new Item(18780), new Item(18781) }; //or i++;
    
        public boolean isEffigy(Player player, Item item) {
            this.item = item; //?
            if (item.getId() == effigy().getId()) { //?
                return true;
            }
            return false;
        }
    
    
        private final Item effigy() {
            return Arrays.stream(EFFIGIES).filter(effigy -> item.getId() == effigy.getId()).findAny().orElse(null);
        }
    wat y lol
    Reply With Quote  
     

  13. Thankful user:


  14. #10  
    1-800-WHY-UMAD

    423 Million's Avatar
    Join Date
    Jul 2013
    Posts
    1,210
    Thanks given
    1
    Thanks received
    356
    Rep Power
    0
    Wow okay lets look through this

    Code:
    private final Object[][] EMOTES = { { new Animation(14177), new Graphics(2692) },
                { new Animation(4068), new Animation(4067) } };
    graphics seems to be called once so make this its own variable (or just place it where it is called)
    make the array 1d, and of type Animation or have a seperate variable for each emote since there are only 3 and name them to the emote it does not emote 1 emote 2 etc, like bow_anim etc.

    Code:
    private static AncientEffigy instance;
    
    
        public static final AncientEffigy getInstance() {
            if (instance == null)
                instance = new AncientEffigy();
            return instance;
        }
    What? No need to make this an object since your specifying the arguments each time (items, player etc.)

    Code:
    public void advanceEffigy(Player player, Item item) {
            player.lock(5);
            player.getInventory().deleteItem(effigy().getId(), 1);
            player.getInventory().addItem(effigy().getId() + 1, 1);
            player.setNextAnimation((Animation) EMOTES[1][0]);
            if (effigy().getId() + 1 == 18782)
                player.setAniAndGfx((Animation) EMOTES[0][0], (Graphics) EMOTES[0][1]);
        }
    Even if you make checks before this method call, do it while in the method to guarantee the player has the item (good habit prevents possible issues later)


    Code:
     private final Item effigy() {
            return Arrays.stream(EFFIGIES).filter(effigy -> item.getId() == effigy.getId()).findAny().orElse(null);
        }
    You're using streams, great. Use optional (stop at findAny()) and change Item to Optional<Item> opposed to returning a possible nulled object.

    Code:
    public int getRequiredLvl(Item item) {
            switch (item.getId()) {
            case 18778:
                return 91;
            case 18779:
                return 93;
            case 18780:
                return 95;
            case 18781:
                return 97;
            }
            return -1;
        }
    switch statements should have default case defined by: default: break;

    also noticed you don't even do checks in the dialogue if the player has the item (bad)

    if you still believe these final (constants) shouldn't be static refer to this: [Only registered and activated users can see links. ]
    TLDR: since it remains 1 value and cannot be changed, static will prevent java from allocating memory to it in every instance

    not trying to hate, just constructive criticism!
    Wish List:

    [Only registered and activated users can see links. ] for vet rank, and unban this man (Bacon Head): [Only registered and activated users can see links. ]
    Reply With Quote  
     

  15. Thankful user:


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)

Similar Threads

  1. Ancient Effigy Animation
    By chaflie in forum Help
    Replies: 4
    Last Post: 10-10-2013, 11:25 PM
  2. [REQ]Ancient effigies Emotes, gfx..
    By Own4g3 in forum Requests
    Replies: 4
    Last Post: 02-22-2012, 05:49 PM
  3. Ancient Effigies..
    By Shakedy in forum Show-off
    Replies: 14
    Last Post: 12-17-2011, 11:20 AM
  4. #Rune-Force - Ancient Effigies
    By chaflie in forum Show-off
    Replies: 33
    Last Post: 12-07-2011, 01:53 PM
  5. Ancient effigies
    By Jason in forum Models
    Replies: 8
    Last Post: 11-06-2010, 11:32 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
  •