Flub 1,282 Posted October 14, 2021 Report Share Posted October 14, 2021 Hey guys, whipped this up quickly. Make sure to add my previous snippets too. Genie.java package com.janus.world.content.randomevents; import com.janus.engine.task.Task; import com.janus.engine.task.TaskManager; import com.janus.model.Animation; import com.janus.model.Graphic; import com.janus.model.Item; import com.janus.model.container.impl.Inventory; import com.janus.world.World; import com.janus.world.entity.impl.npc.NPC; import com.janus.world.entity.impl.player.Player; import lombok.Getter; import lombok.Setter; public class Genie { @Getter @Setter private Player spawnedFor; @Getter @Setter private boolean claimed; public Genie(Player spawnedFor, boolean claimed) { this.spawnedFor = spawnedFor; this.claimed = claimed; } public static final int genieID = 409; private static final int lampID = 18782; private static final Item reward = new Item(lampID, 1); private static final Animation wave = new Animation(863); private static final Graphic smoke = new Graphic(188); public static void spawn(Player player) { String userName = player.getUsername(); Genie genie = player.getGenie(); genie.setClaimed(false); NPC genieNpc = new NPC(409, player.getPosition()); genieNpc.setSpawnedFor(player); World.register(genieNpc); genieNpc.setResetMovementQueue(true); genieNpc.performGraphic(smoke); genieNpc.getMovementQueue().setFollowCharacter(player); genieNpc.performAnimation(wave); genieNpc.forceChat(userName + " I have a reward for you!"); TaskManager.submit(new Task(60, false) { @Override protected void execute() { despawn(genieNpc); } }); } public static void handleInteraction(NPC genieNpc, Player player, int click) { String userName = player.getUsername(); Inventory invent = player.getInventory(); boolean freeSlot = invent.getFreeSlots() >= 1; Genie playerGenie = player.getGenie(); if (genieNpc.getSpawnedFor() == player && !player.getGenie().isClaimed() && playerGenie.getSpawnedFor() == player) { if (!freeSlot) { genieNpc.forceChat("You need to have at least one inventory slot free!"); return; } switch (click) { case 1: invent.add(reward); playerGenie.setClaimed(true); genieNpc.forceChat("Enjoy your reward " + userName + "!"); break; case 2: player.getPacketSender().sendMessage("You dismiss the Genie!"); genieNpc.forceChat("Okay, bye for now " + userName + "!"); break; } despawn(genieNpc); } else if (playerGenie.isClaimed()){ player.getPacketSender().sendMessage("You've already claimed your reward!"); } else { player.getPacketSender().sendMessage("This Genie isn't here for you!"); } } public static void despawn(NPC genieNpc) { if (genieNpc != null) { genieNpc.performAnimation(wave); genieNpc.performGraphic(smoke); TaskManager.submit(new Task(2, false) { @Override protected void execute() { World.deregister(genieNpc); } }); } } } Player.java @Getter @Setter private Genie genie = new Genie(this, false); NPCOptionPacketListener.java First Click: case Genie.genieID: Genie.handleInteraction(npc, player, 1); break; Second Click: case Genie.genieID: Genie.handleInteraction(npc, player, 2); break; SkillManager.java Anywhere in the addExperience method: if (Misc.percentageChance(10.0)) { //Change the value. This is a 10% change of a spawn - Way too high. Genie.spawn(player); } Link to comment Share on other sites More sharing options...
remilol 1 Posted November 7, 2021 Report Share Posted November 7, 2021 Finally some one not just spawning the genie for everyone to click on lol. Link to comment Share on other sites More sharing options...
ExoticDX 0 Posted January 24, 2022 Report Share Posted January 24, 2022 thx u gonna use this Link to comment Share on other sites More sharing options...
shadowisdom 1 Posted February 6, 2022 Report Share Posted February 6, 2022 thanks for this Link to comment Share on other sites More sharing options...
Snooperal 0 Posted April 17, 2022 Report Share Posted April 17, 2022 flub the goat Link to comment Share on other sites More sharing options...
Moose 0 Posted May 26, 2022 Report Share Posted May 26, 2022 Will be very helpful. Thanks Link to comment Share on other sites More sharing options...
0117be 66 Posted June 2, 2022 Report Share Posted June 2, 2022 ooo very nice! Link to comment Share on other sites More sharing options...
sliskes Wrarh 0 Posted October 8, 2022 Report Share Posted October 8, 2022 NICE! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now